So I have a programming lab that we did in class for a few months but I am having major difficulity on it. These are the directions:

``````  Specifications for Calculate grades using loops
``````
1. Create pseudo code for your program first, to be handed in.
2. Make the program user friendly.
3. Use a constant at the top of the program for:
a. Test points percent = 65%
b. Lab. points percent = 25%
c. Note points percent = 25%
4. Make sure you use a loop for each of the three average calculations below.
a. Average Test scores, (add all the test scores and divide by the number of test). Average Lab scores, (add all the lab scores and divide by the number of labs).
b. Average Notes scores, (add all the notes scores and divide by the number of notes).
5. Take the totals from above and multiply them by the respective points.
a. Divide the test average by the test point’s percentage.
b. Divide the lab average by the lab point’s percentage.
c. Divide the notes average by the notes point’s percentage
a. 96.45 and up = A+
b. 92.45 – 96.44 = A
c. 88.45 – 92.44 = B+
d. 84.45 – 88,44 = B
e. 80.45 – 84.44 = C+
f. 76.45 – 80.44 = C
g. 73.45 – 76.44 = D+
h. 69.45 –73.44 = D
i. Less than 69.45 = F
8. End.

And this is the code that I have but I can't see what I did wrong:

``````#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
// Include different students and clear up spaces with breaks.
int main()
{

int test1, test2, test3;
int lab1, lab2, lab3;
int notes1, notes2, notes3;
int name;

float TestAverage = .65;
float LabAverage = .25;
float NotesAverage = .10;

cout << "What is your name?";
cin >> name;

cin >> test1;

cin >> test2;

cin >> test3;

cin >> lab1;

cin >> lab2;

cin >> lab3;

cin >> notes1;

cin >> notes2;

cin >> notes3;

float TestAverage = (test1 + test2 + test3)/3;
float LabAverage = (lab1 + lab2 + lab3)/3;
float NotesAverage = (notes1 + notes2 + notes3)/3;

cin << TestAverage + LabAverage + NotesAverage;

{cout << "Grade = " << Grade << " A+ "; }   else
{cout << "Grade = " << Grade << " A  "; } else
{cout << "Grade = " << Grade << " B+ "; } else
{cout << "Grade = " << Grade << " B  "; } else
{cout << "Grade = " << Grade << " C+  "; } else
{cout << "Grade = " << Grade << " C   "; } else
{cout << "Grade = " << Grade << " D+   "; } else
{cout << "Grade = " << Grade << " D   "; }
else
{cout << " Final grade = " << Grade << " F   "; }
cout << " " << endl;  cout << " " << endl;

system("pause");

return 0;
}
``````

## All 4 Replies

A. Can you specify exactly what went wrong? Do you have compilation error? Does the program give the wrong answer?
B. I think you forgot to define the variable Grade. Grade should be calculated according to section (3) in your assignment.
C. Why do you use `cin << TestAverage + LabAverage + NotesAverage;` when you've already calculated them from input?

Regards,
-FH

P.S.

My program just doesn't start at all, how would I define the varoable grade? I thought I already did when I list them as float's.

(Thanks for the help, Yozuru)

• you haven't created yet a variable grade

float TestAverage = (test1 + test2 + test3)/3;
float LabAverage = (lab1 + lab2 + lab3)/3;
float NotesAverage = (notes1 + notes2 + notes3)/3;

• there's no need to redeclare their data type

cin << TestAverage + LabAverage + NotesAverage;

• you probably meant to store their summed value to grade (which you still need to declare) instead of asking their value from the user

I thought I already did when I list them as float's

the only variables listed as floats are TestAverage, LabAverage, NotesAverage and not grade

Declar grade just like you declare the rest of the variables:
`float Grade;`
Then assign some value to Grade (according to the calculation at section 3).
-FH

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.