I am a beginner and needing help with my coding for my grade calculator. I know that most examples show grade averages for a set number of grades. The thing that I am trying to learn is how would I write it if the number of grades was different for each student. I am having trouble being able to figure out how to put in a function where the user can stop putting in grades for the student whenever they want. I also am trying to put it to where the user enters A,B,C,D,F for the grade and have my program automatically convert it to A=4,B=3, C=2, D=1, F=0, then average up all the grades entered. I am trying to learn this stuff not just looking for a handout, I am just stumped as to where to find help.. THANKS!
Code:
#include <iostream> #include <string> using namespace std; int main() { //Declaring variables char StudentsName [100]; float ExamValue, Sum, Avg,TotalGrades; //Total grades needs to equal # of grades submitted int A = 4;//Need to find a way for the user to input A,B,C,D,F and it turn it to the corr. number// int B = 3; int C = 2; int D = 1; int F = 0; string input = ""; //declaring students name cout << "Enter students name:"; cin >> StudentsName; cout << endl; //declaring grade cout << "Enter Grade must be A,B,C,D, or F:"; cin >> ExamValue; //STILL NEED TO WORK ON THIS EQUATION Avg = Sum / TotalGrades; cout << "Final Grade: " << Avg << endl; //Calculating grade cout << "Grade: "; if (Avg == 100){ cout << "A+" << endl; }else if (Avg < 4 && Avg >= 3){ cout << "A" << endl; }else if (Avg < 3 && Avg >= 2){ cout << "B" << endl; }else if (Avg < 2 && Avg >= 1){ cout << "C" << endl; }else if (Avg < 1 && Avg >= 0){ cout << "D" << endl; }else if (Avg < 0){ cout << "F" << endl; } return 0; }
Comment