Grades c++

Right am new to programing , how do I go about getting students names and scores and the number of passes and the number of fails in a sort of a loop

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 #include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <math.h>
#include <Windows.h>

using namespace std;


int getScore()
{

	system ("color 1f");
	
	
int score = 0; 
char name, grade;

//input score
    cout << "Enter score: ";
    cin >> score;
	cout << "Enter name: ";
	cin >> name;

if (score == 100)
{
    cout <<"You received a perfect score (A*) Did You Cheat lol \n";
    // 100% is an A. BrainBox
}
else if ((score >= 85) && (score <= 100))
{
    cout << "Your grade is an (A*).\t Great Stuff ! \n";
    // 85-100 is an A*.
}
else if ((score >= 70) && (score <= 84))
{
    cout << "Your grade is a just an (A).\t Well done. \n";
    // 70-84 is a A.
}
else if ((score >= 55) && (score <= 69))
{
    cout << "Your grade is a (B).\t Not Bad ? \n";
    // 55-69 is a B.
}
else if ((score >= 40) && (score <= 54))
{
    cout << "Your grade is a (C).\t Still a pass tho . \n";
    // 40-54 is a C.
}
else if ((score >= 0) && (score <= 39))
{
    cout << "You got an F!\t YOU FAIL! GO JOIN THE DOLE QUEUE. \n";
    // 0-39 is an F.FAIL

}
   _getch();
return 0;
}
it would depend on what type of loop you would want. you can put it into a loop to run as many times as you want till you tell it to quit, or have it run a certain number of runs. I would use a while loop. pretty much it would go like this.

int score = 0;
char name,grade;

while( grade != '.')
{
your program you already have

}

return 0;
Garrettww2010, for some reason I can't reply to your other message about arrays inside a function. Sorry to hijack this thread.

Your code there is off track. Follow what the professor requested. Here is an example of what smallest() might look like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void smallest(void)
{
    cout << "How many values: " << flush;
    int size = sizeOfArray();
    double values[size];
    for (int i=0; i<size; ++i) {
        values[i] = getInputs();
    }
    int frequency=0;
    double smallest = findSmallest(values, frequency, size);
    display(values, smallest, frequency, size);
    cout << "strike any key to continue";
    char ch;
    cin >> ch;
}
Topic archived. No new replies allowed.