Well, this is my first c++ program assignment.
I was pretty proud of myself after I finished it but I'm having a small problem.
This program is designed to output a few weighted grades from a set of 4 scores.
The quizzes need to be weighted at 30% and the tests weighted at 70%
It's set up, and I think it runs just fine, but my problem is, my weighted scores are not the same as the example's is
The sample output is
How many student you want to process:
1
Enter next student’s name:
Doug Talbert
Enter quiz 1 quiz 2 test 1 and test 2 scores of Doug Talbert:
93 96 99 97
Name: Doug Talbert
Quiz: 27
Test: 67
Total: 94
Grade: A
Here is my output
How many student you want to process:
1
Enter next student’s name:
Doug Talbert
Enter quiz 1 quiz 2 test 1 and test 2 scores of Doug Talbert:
93 96 99 97
Name: Doug Talbert
Quiz: 28.35
Test: 68.6
Total: 96
Grade: A
http://img571.imageshack.us/img571/379/problemeu.jpg
As you can see, I'm not getting exactly what I should.
Also, I have one more problem, how do I get rid of those pesky decimals :P
Code:
/*****************************\
* *
* 9/30/2010 *
* Programming Assignment 1 *
\*****************************/
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
int main(){
int totalquiz,totaltest,total,students,quiz1,quiz2,test1,test2;
char grade;
char name[21];
cout << "How many student you want to process: ";
cin >> students;
cout << endl;
if (students >=1){
if (students<=50){
while (students){
cin.ignore();
cout << "Enter next student's name: ";
cin.getline (name,21);
cout << endl;
cout << "Enter quiz 1 quiz 2 test 1 and test 2 scores of " << name << " ";
cin >> quiz1 >> quiz2 >> test1 >> test2;
totalquiz = (quiz1+quiz2) / 2 * .3 ;
totaltest = (test1+test2) / 2 * .7 ;
total = totalquiz + totaltest;
if (total >= 90)
grade = 'A';
else if (total >= 80)
grade = 'B';
else if (total >= 70)
grade = 'C';
else if (total >= 60)
grade = 'D';
else if (total < 60)
grade = 'F';
cout << endl;
cout << setw(15) << "Name:" << setw(21) << name << endl;
cout << setw(15) << "Quiz:" << setw(21) << totalquiz << endl;
cout << setw(15) << "Test:" << setw(21) << totaltest << endl;
cout << setw(16) << "Total:" << setw(20) << total << endl;
cout << setw(16) << "Grade:" << setw(19) << grade << endl << endl;
students--;
}
}
else{
cout << "Number of students must be 50 or less, please try again\n";
return 0;}
}
else{
cout << "Number of students must be a number over 0, please try again\n";
return 0;}
}