Gradebook program

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;

//Get average assignment score
averageScore = (assignmentScore1 + assignmentScore2 + assignmentScore3) / 3;
std::cout << "Average score is:" << averageScore << endl;
Here's a tutorial to help you out:
http://www.cplusplus.com/doc/tutorial/

Also, no one will help you do your homework for you, just fyi. :D
http://www.cplusplus.com/forum/beginner/1/

Hope this helps,

~Hirokachi
Last edited on
Im not looking for anyone to do it for me. Im just looking for some general direction
Ok that's good! :D

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

If not, here's that same tutorial but at control structures part:
http://www.cplusplus.com/doc/tutorial/control/

Have fun,

~Hirokachi
Last edited on
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 ?
It is okay!

In fact, it is the best way to do this problem.

Although, maybe you want to look into arrays and if it's something that you can do based on the assignment. You should totally look into it.

Here's a nice tutorial to look at and it's on this site too:
http://www.cplusplus.com/doc/tutorial/arrays/

Have fun, my friend!

~Hirokachi

Edit: yes you can use the output handler found on this tutorial: http://www.cplusplus.com/doc/tutorial/files/
Last edited on
Topic archived. No new replies allowed.