I've wrestled with this for hours. Help me learn where I've gone wrong and what I can do to make it right & most of all WHY?
Here's the prompt:
Write a C++ program to output information for three students. The information stored in your program contains student’s first name, middle name, last name, and test score. The following shows the information for the three students, where test score (e.g. 78) is in the int type.
John Jacob Smith 78
Mary Jane Weems 82
Dave Joe Dale 61
Your program should declare three named string constants for the three students. Each constant contains the student’s first name, middle name, and last name. You may use three int variables to hold values for the three test scores. The first name, middle name, and last name of a student are then extracted using the substr() function shown in class. Your program should also compute the average (in floating-point number format) for the three test scores. The average score computed should be printed to the screen with 2 digits displayed after the decimal point.
The following shows the output from the program. Note that all the output is left-justified with 15 character positions reserved for each.
first name middle name last name test score average
John Jacob Smith 78 73.67
Mary Jane Weems 82 73.67
Dave Joe Dale 61 73.67
I notice a few errors immediately: first, string1 has no type; second, string2 and string3 are declared as integers rather than strings; and third, you need to use the dot operator to access the substr() method of string1.
What exactly are you having trouble with regarding the assignment?
let me rephrase your question and see if that helps...
Your program should declare three named string constants for the three students. Each constant contains the student’s first name, middle name, and last name.
So you were wrong to include their ages in there.
These are also students so calling the variables "string" is confusing
1 2 3
const string student1 = "John Jacob Smith";
const string student2 = "Mary Jane Weems;
const string student3 = "Dave Joe Dale";
You may use three int variables to hold values for the three test scores.
You still need to code this. You included the scores in the name text which was incorrect.
The first name, middle name, and last name of a student are then extracted using the substr() function shown in class.
You misunderstood this and extracted the entire name.
Your program should also compute the average (in floating-point number format) for the three test scores.
This will be more obvious when you put the int's in.
The average score computed should be printed to the screen with 2 digits displayed after the decimal point.
Again, this will be more obvious after you've done the int's and computed the average.