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
  6. Add the points together to find the number grade.
  7. Print out the letter grade next to the numeric grade.
    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;

cout << "What is your first test grade? ";
cin >> test1;

cout << "What is your second test grade? ";
cin >> test2;

cout << "What is your third test grade? ";
cin >> test3;

cout << "What is your first lab grade? ";
cin >> lab1;

cout << "What is your second lab grade? ";
cin >> lab2;

cout << "What is your third lab grade? ";
cin >> lab3;

cout << "What is your first notes grade? ";
cin >> notes1;

cout << "What is your second notes grade? ";
cin >> notes2;

cout << "What is your third notes grade? ";
cin >> notes3;


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

cout << "Your grade average is... ";
cin << TestAverage + LabAverage + NotesAverage;

      if (Grade > 96.45 )
     {cout << "Grade = " << Grade << " A+ "; }   else   
       if (Grade > 92.45 && Grade < 96.45)
       {cout << "Grade = " << Grade << " A  "; } else
         if (Grade > 88.45 && Grade < 92.45)
         {cout << "Grade = " << Grade << " B+ "; } else
           if (Grade > 84.45 && Grade < 88.45)
           {cout << "Grade = " << Grade << " B  "; } else
             if (Grade > 80.45 && Grade < 84.45)
             {cout << "Grade = " << Grade << " C+  "; } else           
               if (Grade > 76.45 && Grade < 80.45)
               {cout << "Grade = " << Grade << " C   "; } else          
                 if (Grade > 73.45 && Grade < 76.45)
                 {cout << "Grade = " << Grade << " D+   "; } else          
                   if (Grade > 69.45 && Grade < 73.45)
                   {cout << "Grade = " << Grade << " D   "; }   
                   else
                   {cout << " Final grade = " << Grade << " F   "; } 
         cout << " " << endl;  cout << " " << endl;                


        system("pause");

    return 0;
}

Recommended Answers

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.
Next time please use the Formatting Help Link before posting, to make your code more readable.

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, networking, learning, and sharing knowledge.