I been learning by myself C++ programming for a month now and I'm now taking classes to learn more about it and how to use it. My teacher gave us our 3rd C++ assignment. She ask us to take 10 students grades and enter them. The program is then, suppose to tell what their grade is. After that, we're suppose to put in the grade the program gave us and the program converts it into a letter grade (like A+,A, B+,B, C+,C, etc). Finally, it suppose to show the student's average and the course average.
I posted this on Sunday and got a lot of help (Thanks guys!!!!) and I modify the code after that to match the project but there's still something werid with it.
I've been trying to type a code that's does this, and I was able to run it but not the way it suppose to be. Here my code:
#include <iostream.h>
#include <iomanip>
using namespace std;
int main()
{
int grade = 0.0;
short studentID = 10;
const int numTests = 1;
char courseId = ' ';
double classAverage = 0;
int numStuds;
double courseSumScores = 0.0;
//Enter Course Name
cout << "Enter Course ID Number (1->Business Law): ";
cin >> courseId;
if (courseId == '1')
cout << "Course Type Accepted";
else //default
cout << "Invalid Course Type";
//end if
cout << endl;
//Enter Student ID
cout << "Number of students ID#---> " << flush;
cin >> studentID;
studentID = toupper(studentID);
switch (studentID)
{
case 1234:
cout << "Student Grade is: 87";
break;
case 2345:
cout << "Student Grade is: 76";
break;
case 3456:
cout << "Student Grade is: 45";
break;
case 4567:
cout << "Student Grade is: 89";
break;
case 5678:
cout << "Student Grade is: 103";
break;
// Enter the Number Grade.
cout << "Enter Number Grade: ";
cin >> grade;
grade = toupper(grade);
if (grade >= 89.5)
cout << "Student's Letter Grade is: A";
else if (grade >= 84.5)
cout << "Student's Letter Grade is: B+";
else if (grade >= 79.5)
cout << "Student's Letter Grade is: B";
else if (grade >= 74.5)
cout << "Student's Letter Grade is: C+";
else if (grade >= 69.5)
cout << "Student's Letter Grade is: C";
else if (grade >= 64.5)
cout << "Student's Letter Grade is: D+";
else if (grade >= 59.5)
cout << "Student's Letter Grade is: D";
else if (grade <= 59.4)
cout << "Student's Letter Grade is: F";
else //default
cout << "Invalid Grade";
//end if
// we have ten students
int Index = 0
for (Index =0; Index != 10; ++Index)
{
// read in student info...
std::cin >> (int)StudentID >> (float)studentGrade;
// are we in a file or user input for all the info...
// we should have an Id and Grade for that Id that is read in from user or file.
// process information.
// if grade is between xx and yy it has grade Some grade. it looks like you have this if ladder as it should be
std::cout << "Student Id#" << studentID << " has a grade of " << (float)StudentGrade << "//" << (string)LetterGrade << std::endl;
// The average accumlator
TotalGrade+= CurrentGrade;
} // end of for loop
// dump the average...
float Average = TotalGrade / 10;
std::cout << "Average Grade :" << Average << "//";
// process the letter grade for the average
std::cout << (string)AverageLetterGrade << std::endl;
this is basically what you are trying to do without all the code only small hints. We don't do homework on this site. Most of who can program could do these in our sleep and it your learning process.
The bottom line will never happen, actually none of them would work accurately, grade is an integer, meaning it cannot hold a fractional value.
There's no point in writing a bunch of code and hoping It'll work. Even if your program appears to run, it is bug ridden by flawed logic and structure.