Basic Grade Calculator

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "stdafx.h"
#include <iostream>
using namespace std; 

int main()
{
	int grade[13];
	int outof[13];
	int gradeTotal;
	int outofTotal;
	float finalGrade;
	{
	 		cout<<"Please Enter Your First Grade ";
			cin>>grade[0]; 
			cout<<"Out of ";
			cin>>outof[0];
		cout<<"Please Enter Your Second Grade ";
			cin>>grade[1];
			cout<<"Out of ";
			cin>>outof[1];
		cout<<"Please Enter Your Third Grade ";
			cin>>grade[2];
			cout<<"Out of ";
			cin>>outof[2];
		cout<<"Please Enter Your Fourth Grade ";
			cin>>grade[3];
			cout<<"Out of ";
			cin>>outof[3];
		cout<<"Please Enter Your Fifth Grade ";
			cin>>grade[4];
			cout<<"Out of ";
			cin>>outof[4];
		cout<<"Please Enter Your Sixth Grade ";
			cin>>grade[5];
			cout<<"Out of ";
			cin>>outof[5];
		cout<<"Please Enter Your Seventh Grade ";
			cin>>grade[6];
			cout<<"Out of ";
			cin>>outof[6];
        cout<<"Please Enter Your Eight Grade ";
			cin>>grade[7];
			cout<<"Out of ";
			cin>>outof[7];
        cout<<"Please Enter Your Ninth Grade ";
			cin>>grade[8];
			cout<<"Out of ";
			cin>>outof[8];
        cout<<"Please Enter Your Tenth Grade ";
			cin>>grade[9];
			cout<<"Out of ";
			cin>>outof[9];
        cout<<"Please Enter Your Eleventh Grade ";
			cin>>grade[10];
			cout<<"Out of ";
			cin>>outof[10];
        cout<<"Please Enter Your Twelth Grade ";
			cin>>grade[11];
			cout<<"Out of ";
			cin>>outof[11];
		cout<<"Please Enter Your Thirtheenth Grade ";
			cin>>grade[12];
			cout<<"Out of ";
			cin>>outof[12];
	
	gradeTotal=(grade[0]+
		        grade[1]+
				grade[2]+
				grade[3]+
				grade[4]+
				grade[5]+
				grade[6]+
				grade[7]+
				grade[8]+
				grade[9]+
				grade[10]+
				grade[11]+
				grade[12]);

	outofTotal=(outof[0]+
				outof[1]+
				outof[2]+
				outof[3]+
				outof[4]+
				outof[5]+
				outof[6]+
				outof[7]+
				outof[8]+
				outof[9]+
				outof[10]+
				outof[11]+
				outof[12]);
		finalGrade=gradeTotal/outofTotal*100;
		cout<< " Your grade is "<<finalGrade<<endl;
	}
	system ("Pause");
	return 0;
}



Can someone help me I can't seem to figure out why ever time I input all of my grades it give me my grade as 0? Thanks
finalGrade=gradeTotal/outofTotal*100;
You're dividing two integers, which will always give an integer result.
(e.g. 50/100 = 0, although 50.0/100 = 0.5)

Easiest way to fix that is to cast one of them to float.
finalGrade = ((float)gradeTotal) / outofTotal * 100;
Alright thanks i appriciate it!
Topic archived. No new replies allowed.