I have been asked to write a gradebook program where you ask the user to enter a students first and last name, their major, and then enter three assignment scores. The program should then allow the user to find the average score for each student. I have been able to do all but I Also I have to make this for three seperate students, how would I adjust this so that the same questions are asked for three different students and then find the minimum and maximum score for each assignment as well as the mean score for each assignment? This is my first code I have attempted to write and any help would be greatly appreciated.
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
int rank;
int assignmentScore1;
int assignmentScore2;
int assignmentScore3;
int averageScore;
string firstName;
string lastName;
string major;
// Get student's first name
std::cout << "Enter the student's first name. ";
std::cin >> firstName;
// Get student's last name
std::cout << "Enter the student's last name. ";
std::cin >> lastName;
// Get student's major
std::cout << "Enter the student's major. ";
std::cin >> major;
// Get 1st assignment score
; std::cout << "Enter the student's score for assignment 1. ";
std::cin >> assignmentScore1;
// Get assignment score 2
std::cout << "Enter the student's score for assignment 2. ";
std::cin >> assignmentScore2;
// Get assignment score 3
std::cout << "Enter the student's score for assignment 3. ";
std::cin >> assignmentScore3;
Just for the future, this forum is used for errors you don't know and for some reason you can't find/understand the answer and if you aren't sure how to solve a specific problem.
I see you want to get three students, right now you are only getting one.
Here's a general question to help point you in the correct direction:
Do you know about for loops? If so this is a great opportunity for one. :D
Yes i have been looking into them but most of the examples that I see are doing the same thing unitl the criteria is met which obviously is what its suppose to do, however im not sure how to apply it to my case where I want the user to enter NEW data for each one and then save that each time. I guess im just struggling to apply it to my case. Is there any example that you could show me that would help me apply it to my case?? Thanks!
Actually i think i got it. at the top of the loop i wrote
for (count = 0; count <= 2; count++)
{
}
This allowed it to execute only three times. Is that okay to do?
Also could i use output handler to save these to a txt file ?