Hi All,
I'm almost halfway through the semester and so far so good, they give us one week to write a program, however, my 70 year old mother was in a car accident last week, and honestly, I had not even opened the assignments (online class) until today. Of course, I have to write a program that is due before midnight and I don't even know where to begin.
I would be very grateful if someone can assist.
Here is the assignment:
The logic needed here is complex!!! Pseudo code your logic first then work one piece of the code at a time, Don't forget to ensure the validity of the input.
Create a program to handle a college class grades:
Capture the Teacher's name
Capture the Class designation
The program should ask how many students are in the class and do the following for each student:
Read the students name
Read in up to 10 grades for the student (from 0 - 100 is acceptable. If outside the range don't use the input, ask for a correction , 999 should stop input of grades if there are less than 10)
Calculate the average of the student's grades
Compute the student's grade as a letter grade
For the entire class
Compute the class's grade average
Determine how many A's, B's, C's, D's and F's are in the class.
Write the following data to a file called class_statistics.txt
Teacher: Bob Marley
Class: CGS1010
Student Name: Jim Beam Average: 88 Grade: B
Donna Jenner 95 A
Student count: 2
Student average: 91.5
A's: 1
B's: 1
C's: 0
D's: 0
F's: 0
"The logic needed here is complex!!!" Lol, I really hope you aren't a CS major. Post the code you have so far, then I'll attempt to help you, so will others.
Oh, I thought you posted that lol. Yea just post the code you have already. All you need to do is get input and do minor minor calculations. This should be a very easy to write
You need to post your code like this or no one will help you on this site but I'll try to address some things to help you out.. Don't even worry about printFileToScreen function for now, you aren't even using it. Focus on getting the main parts of your program working first. Looks like you need to get input from the user and ask how many students are in the class. Do you know how to do that?
Ok so then my question would be is how would the program know from the students which ones to take. In his example he has two students, but if we leave that open, and let's say we don't have those students defined, then how would the program know?
BTW thank you so much for being patient. I work for an airline, if you ever need a buddy pass you can email me (it's a small airline so hopefully it flies from your nearest airport)
#include<iostream>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<string>
#include<vector>
usingnamespace std;
//Global
int aStudentAvg = 0;
string aStudentGrade = "";
void letterGrade(int num)
{
if (num >= 0 && num <= 59)
aStudentGrade = "F";
if (num > 59 && num <= 69)
aStudentGrade = "D";
if (num > 69 && num <= 79)
aStudentGrade = "C";
if (num > 79 && num <= 89)
aStudentGrade = "B";
if (num > 89 && num <= 100)
aStudentGrade = "A";
}
int main()
{
//Vars
int numberOfStudents = 0;
vector<int> studentGrades;
vector<string> studentNames;
vector<int> studentAverages;
//Ask how many students are in the class?
cout << "\nHow many students are in the class? "; cin >> numberOfStudents;
//Read in the student's name and the student's grade
for (int i = 0; i < numberOfStudents; i++)
{
//Store student name and grades in temporary variable
string tempStudent;
string tempGrade;
//Store the student name in a vector
cout << "Enter the name for student # " << (i + 1) << ": "; cin.ignore(); getline(cin, tempStudent);
studentNames.push_back(tempStudent);
//Loop through 10 grades
for (int j = 0; j < 10; j++)
{
//Store the student grade in a vector (and convert it to a integer so we can do calculations on it)
cout << "Enter the grades for the student " << "(" << (j+1) << ")" << ": "; cin >> tempGrade;
studentGrades.push_back(stoi(tempGrade));
}
//Get the student's average
for (int k = 0; k < studentGrades.size(); k++)
{
//Sum up all grades
aStudentAvg += studentGrades[k];
}
//To hold a student's average
aStudentAvg = aStudentAvg / (studentGrades.size());
}
//Get Letter Grade
letterGrade(aStudentAvg);
//Display the student's average grade.
cout << endl;
cout << "Teacher: Bob Marley" << endl;
cout << "Class: CGS101" << endl;
cout << "Student Name: " << studentNames[0] << " Average: " << aStudentAvg << " (" << aStudentGrade << ")" << endl;
cout << "Student Count: " << numberOfStudents;
cout << endl;
//End of Program
return 0;
}