percentage mark

closed account (1RLTURfi)
somebody help.the final score got a bit problem.i input exam-86,quiz-84,assg-70,lab-88,test-80,the final score should give me 82.7,but my program give me 82 only..someone help..


#include <iostream>
#include <cmath>
using namespace std;

int get_Score(double,double,double,double,double);

int main()


{
int a ;
double score, b , c , d , e , f ;


cout << "Please enter your student number." << endl;
cin >> a;

cout << "\nPlease enter your marks for exam." << endl;
cin >> b;

cout << "\nPlease enter your marks for quiz." << endl;
cin >> c;

cout << "\nPlease enter your marks for prigramming assignment." << endl;
cin >> d;

cout << "\nPlease enter your marks for lab exercise." << endl;
cin >> e;

cout << "\nPlease enter your marks for test." << endl;
cin >> f;

score = get_Score(b, c ,d , e ,f );

cout << "\nStudent Number:" << " " << a << endl;
cout << "=======================";
cout << "\nMarks for exam is:" << " " << b << endl;
cout << "Marks for quiz is:" << " " << c << endl;
cout << "Marks for programming assignment is:" << " " << d << endl;
cout << "Marks for lab exercise is:" << " " << e << endl;
cout << "Marks for test is:" << " " << f << endl;
cout << "Final Score is" << " " << score << endl;






system ("pause");

return 0;

}

int get_Score(double b ,double c ,double d ,double e , double f)
{
double score;

score = ( (b / 100) * 30 ) + ( ( c / 100) * 10 ) + ( ( d / 100) * 15 ) + ( ( e / 100) * 25) + ( ( f / 100) * 20);

return score ;
}




check the return type of get_Score
closed account (2EyCpfjN)
First of all, I recommend that you fix your typo:
Please enter your marks for prigramming assignment

:p
double get_Score(double b ,double c ,double d ,double e , double f)
closed account (2EyCpfjN)
right, what dishanf said.
but here's how I re-did your stuff :p you sort of waste your time toward the bottom.
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
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;

int get_Score(double,double,double,double,double); // <-- What is the point in this line of code? (I'm new)
/*
int get_Score(double b, double c, double d, double e, double f)
{
	double score;
	score = ( (b / 100) * 30 ) + ( ( c / 100) * 10 ) + ( ( d / 100) * 15 ) + ( ( e / 100) * 25) + ( ( f / 100) * 20);
	return score ;
}
*/
double get_Score_test(double b, double c, double d, double e, double f)
{
	double avg_b = (b / 100) * 30; // finds average of b
	double avg_c = (c / 100) * 10; // finds average of c
	double avg_d = (d / 100) * 15; // finds average of d
	double avg_e = (e / 100) * 25; // finds average of e
	double avg_f = (f / 100) * 20; // finds average of f
	double avg_a = (avg_b + avg_c + avg_d + avg_e + avg_f);
	return avg_a;
}

int main()
{
	int a ;
	double score;
	double b;
	double c;
	double d;
	double e;
	double f;

	cout << "Student number:\n";
	cin >> a;

	cout << "\nExam:\n";
	cin >> b;

	cout << "\nQuiz:\n";
	cin >> c;

	cout << "\nProgramming:\n";
	cin >> d;

	cout << "\nLab:\n";
	cin >> e;

	cout << "\nTest:\n";
	cin >> f;

	score = get_Score_test(b, c, d, e, f);

	cout << "\nStudent Number: " << a; // Don't complicate this with cout << "........:" << " " << (var) << endl;
	cout << "\n======================="; // Just cout << "\n....: " << (var); add the new line before the text. Or whatever floats your boat.
	cout << "\nExam: " << b;
	cout << "\nQuiz: " << c;
	cout << "\nProgramming: " << d;
	cout << "\nLab: " << e;
	cout << "\nTest: " << f;
	cout << "\nFinal Score: " << score << "\n";


	system ("pause"); // <-- Whatever floats your boat
	return 0;
}


someone tell me if I can do anything better (I'm new, it ran for me), I want critique but keep in mind I'm no pro or anything :)

I like how one of the variables is double d;
:p
Last edited on
closed account (1RLTURfi)
very thank you for everyone.you all help me a lot.i solved it already.
a pierce o wrote:
 
int get_Score(double,double,double,double,double); // <-- What is the point in this line of code? (I'm new) 


"http://www.cplusplus.com/doc/tutorial/functions2/" Declaring functions. (last title)
Topic archived. No new replies allowed.