I'm having trouble writing a for loop. I'm trying to code something like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
float val1, val2, val3;
int maxpts, totppts, i, numberofprograms;
cout << "Enter the number of programs that have been completed: ";
cin >> numberofprograms;
for (i=0; i <= numberofprograms; i++)
{
cout << "Enter the grade for Program ";
cin >> val2;
cout << "Enter the maximum possible points for Program ";
cin >> val3;
val2 + totppts;
val3 + totppts;
}
|
The code runs, but I want it to add a number after program. So when I ask how many programs have been completed and it will run the loop that many times. It should resemble this :
Enter the number of programs that have been completed: 3
Enter the grade for Program 1: 49
Enter the maximum possible points for Program 1: 50
Enter the grade for Program 2: 73
Enter the maximum possible points for Program 2: 75
Enter the grade for Program 3: 96
Enter the maximum possible points for Program 3: 100
**Also came across another problem while doing a do while loop. It seems similar to the part before but is is in a do while loop so I'm a little confused.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
cout << "\nEnter the number of quizzes that have been completed: ";
cin >> numberofquizzes;
do
{
(i=1; i <= numberofquizzes; i++)
cout << "\nEnter the grade for Quiz ";
cin >> val4;
cout << "\nEnter the sum of the two lowest quizzes";
cin >> val5;
while
|
This is how it should look printed out :
Enter the number of quizzes that have been completed: 3
Enter the grade for Quiz 1: 10
Enter the grade for Quiz 2: 10
Enter the grade for Quiz 3: 9
Enter the sum of the two lowest quizzes: 19
So it is very similar to the for loop but I don't know what goes where.
I'm supposed to take the two lowest quiz scores and add them up. Is that what I would put in the while statement? and then everything else is under do?