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;

	}
	
}

line 77: you can't call a constructor after instantiating the class objest (line 56). After that you must call the set functions.

students[i].setName(FirstName, LastName);
students[i].setID(id);

Make the score and point values part of the class so that you can easily match them up with the student.

and how do "Make the score and point values part of the class so that you can easily match them up with the student. "? remeber it took me a week to get this far, i had a hard enough time with creating the first class.

Simple:

class Student
{
private:
	string firstName;
	string lastName;
	int idNum;
   int score;
   int pointes;

	
public:
<snip>

but how do i use that to call the test scores later and display them in the for loop thing? and alo how would i stop the for loop if i ran out of names before i got to twenty? i know i need a while loop but dont know how to make one? and thanks for all your help so far

>>but how do i use that to call the test scores later and display them in the for loop thing?
Just like you did with the other class variables

for(int i = 0; i < number_class_objects; i++)
{
    cout << students[i].grades;
}

>>and alo how would i stop the for loop if i ran out of names before i got to twenty?
There are lots of ways to do that. One way is to ask the question at the end of the loop.

for(int i = 0; i < maxStudents; i++)
{
   <snip>
   char answer;
   cout << "Enter another student info (y or n) ?\n";
   cin >> answer;
   if(answer == 'N' || answer == 'n')
       break;
}

what dose <snip> mean and sorry but i also ment to ask how do i input in the test scores and points?

>>what dose <snip> mean
It just means I left out code, like snipping with a pair of sizzers.

>>how do i input in the test scores and points?
Just like you did all the others. Look to see what you already did and you will have the answer.

Great Thanks! ur the best!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.