![]() |
Build a GPA Calculator Using C++
Hello every1 well I'm taking C++ and I have an assignment for tomorow where I should build a GPA calculator using C++.
Tawa was helping me do it but it seems that we are stuck and we don't know how to continue(At least I don't:p). “GPA Calculator” You are asked to develop a GPA calculator with the following features:
System of Grades The University uses the following system of grades. This system consists of letter grades with their corresponding numerical ranges (i.e. percentage equivalent, and the 4.0 point maximum). http://img36.imageshack.us/img36/3059/15178804.jpg Grade-Point Average The grade-point-average (GPA) or index is the ratio of the total quality point values divided by the number of the credit hours attempted by the student, as shown below. The GPA of the five courses would then be 30.6 / 14 = 2.19. Courses with a grade of W, U, PR or I are not counted in computing the cumulative GPA. The code that I wrote(with the help of tawa). Code:
#include <iostream>ie when I enter for example that I take 4 courses, and I have the following grades: 80,94,87 and 89. and each course has 3 credits so GPA will be 3.5 but using the program above it will give me 3.3 and I know that the problem is in the if and else statement but I don't know how to fix it again. NOTE:I am asked to build the program using only the for loop and if and else statements. Note 2: I have to submit the assignment before today's midnight:D so Edgard chammas chidd el hemme:p |
i'm a C++ n00b but in if statement eza 7attet two equations i think u have to put like this :
else if(GPA >= 66 && GPA <= 69) becomes else if( (GPA >= 66) && (GPA <= 69) ) every operation should be in a bracket. |
Quote:
Anyways, you're wrong, if you calculate the 4 numbers you gave {80,94,87 and 89} You get a GPA of 87.5%, and if you check the table you gave: http://img36.imageshack.us/img36/3059/15178804.jpg 85-88 ~> 3.3 Quality Point Value. Enta mdayya3, just send him this code and you'll do fine. |
The error comes from here:
(80x3) + (94x3) + (87x3) + (89x3) = 1050 1050 / 12 = 87.5 GPA => 3.3 You are using this method to evaluate the GPA. You are getting the average grade of the courses and then passing it to the IF conditions and testing it against the "Quality point value" rule. This is a logical mistake and not a programming one. What you should do is use IF conditions after each grade input, to convert that grade to its equivalent Quality point value. You have another mistake. GPA variable must be declared as double. You will have to do it like this: Code:
#include <iostream> |
Quote:
was goind to post the saaame thang!, btw why people dont use void main :p w yertei7o men el return 0 :D ? if ya need some help later on 2ebba7bechlak bi my C++ notebook we did the same program in class but not GPA (bala ma te2sema ye3neh). |
Thanks guyz,w tawa la twekhizna int kent ketib el program kello:D
anyway the code sar hek Code:
#include <iostream>the output is like this: http://img291.imageshack.us/img291/3342/outputc.jpg u c bi ekhir line kello mni7 min 3ada / F / 0.0 bla bla kif fina nzabbeton w tnx salaf:) |
LOL man, GPA is 3.5 which is wayyyyyyyyyyyyyyyy less than 60, it will keep displaying F :P
zabbeta anyway you want. i made it clear. |
Oh, ma ntabahet. After computing the GPA and outputting the value, why would you need this part?
Quote:
|
Thanks, meche el 7al,choukran jazilan ya edgard:W
|
what you need to do is getting some quality in your code...too much if statements is NOT a good style after all...
you can use switch case way... or you can hide the if else sh*t in a library and use a function to call it. (this function takes the result and return the equivalent value... ) i can't believe that tawa failed in this simple task ( simple compared to the snake game ) |
| All times are GMT +1. The time now is 10:11 PM. |
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger