I am trying to firgure a way to store test scores to a arr or something so i can sotre 20 different scores and twenty different possible points values. but i cant seem to get it right i have almost everything done acept storeing the vales so i can recall them later in my for staement. please help. it also uses a class for the student names and id numbers, maybe i need to put the test score and possible test score in the class i sont know? that is why i am asking for your help. if i do need to make any changes please show me how to do them it took me about a week to get this far. so i need as much assistance as i can get. please help. thanks.
P.S. i have also uploaded the .cpp file as an attachment for convinience.
#include <iostream>
#include <string>
using namespace std;
class Student
{
private:
string firstName;
string lastName;
int idNum;
public:
void setID(int id);
void setName(string fn, string ln);
void printID();
void printName();
Student(); // constructor
Student(string, string, int); // constructor
};
Student::Student()
{
idNum = 9999;
}
Student::Student(string fn, string ln, int id)
{
firstName = fn;
lastName = ln;
idNum = id;
}
void Student::setID(int id)
{
idNum = id;
}
void Student::setName(string fn, string ln)
{
firstName = fn;
lastName = ln;
}
void Student::printID()
{
cout << "Student ID: " << idNum << endl;
}
void Student::printName()
{
cout << "Name: " << firstName << " " << lastName << endl;
}
void main()
{
Student students[20];
string first, last;
int id;
int poss;
int test;
cout << "Eneter student information as first name, last name, id seperated with spaces \n "<<endl;
cout << "(Example: John Doe 1212) "<<endl;
for(int i=0; i<2; ++i)
{
cout << "Student : "<< endl;
cin >> first>>last>>id;
cout << "Enter Test Score" << endl;
cin >> test;
cout << "Enter possible points: "<<endl;
cin >> poss;
students[i] = Student(first, last, id);
}
for (int i=0; i<2; ++i)
{
cout << endl;
students[i].printID();
students[i].printName();
cout << "This student earned "<<test<<" out of "<<poss<<". Letter grade is"<<endl;
}
}