I have a problem where the user enters in their grades from their homework and exams and then the program will tell the user what their grade is. I have everything worked out below but I am missing one key aspect. There are 12 homeworks and only the best 10 are used. How would I go about extracting the best 10 homeworks out of the 12 that are entered??

/************************************************
**  Author          :   darklich13
**  Program         :   hw11, q4
**  Date Created        :   Nov 26, 2007
**  Date Last Modified  :   Nov 26, 2007


Will accept from keyboard your grades for this course
and generate the overall points out of 100 and the
equivalent letter grade based on the information
on the syllabus.


Homeworks (best 10 out of 12)   50%
Exams I & II    16%
Final Exam (comprehensive)  24%
Class Participation and attendance  10%


Grading Scale: (inclusive)


A+   97-100
A    92-96
A-  90-91
B+  88-89
B    82-87
B-  80-81
C+  78-79
C    72-77
C-  70-71
D+  68-69
D    60-67
E    0-59



**************************************************/


#include <iostream>
#include <iomanip>


using namespace std;


int main () {


// Set Variables


double hw1, hw2, hw3, hw4, hw5, hw6, hw7, hw8, hw9, hw10, hw11, hw12;  // Homework Variables
double exam1, exam2, final, PA;  // Variables for tests and Participation and Attendance
double total;


// Ask user to enter their scores


cout << "Enter Grade for Homework 1 (out of 100) : ";
cin >> hw1;
cout << "Enter Grade for Homework 2 (out of 100) : ";
cin >> hw2;
cout << "Enter Grade for Homework 3 (out of 100) : ";
cin >> hw3;
cout << "Enter Grade for Homework 4 (out of 100) : ";
cin >> hw4;
cout << "Enter Grade for Homework 5 (out of 100) : ";
cin >> hw5;
cout << "Enter Grade for Homework 6 (out of 100) : ";
cin >> hw6;
cout << "Enter Grade for Homework 7 (out of 100) : ";
cin >> hw7;
cout << "Enter Grade for Homework 8 (out of 100) : ";
cin >> hw8;
cout << "Enter Grade for Homework 9 (out of 100) : ";
cin >> hw9;
cout << "Enter Grade for Homework 10 (out of 100) : ";
cin >> hw10;
cout << "Enter Grade for Homework 11 (out of 100) : ";
cin >> hw11;
cout << "Enter Grade for Homework 12 (out of 100) : ";
cin >> hw12;


cout << endl << endl;


cout << "Enter Grade for Exam 1 (out of 100) : ";
cin >> exam1;
cout << "Enter Grade for Exam 2 (out of 100) : ";
cin >> exam2;
cout << "Enter Grade for Final Exam (out of 100) : ";
cin >> final;
cout << "Enter Grade for Participation and Attendance (out of 100) : ";
cin >> PA;


total =  ((hw1 * 0.7) + (hw2 * 0.7) + (hw3 * 0.7) + (hw4 * 0.7) +
(hw5 * 0.7) + (hw6 * 0.7) + (hw7 * 0.7) + (hw8 * 0.7) +
(hw9 * 0.7) + (hw10 * 0.7) +
(exam1 * 1.12) + (exam2 * 1.12) + (final * 3.36) + (PA * 1.4))/14;


cout << "Overall Grade out of 100 is " << total << endl;
cout << "Your letter grade is : ";


if ( total >= 97 ) {
cout << "A+" << endl << endl;
}
else if ( total >= 92 ) {
cout << "A" << endl << endl;
}
else if ( total >= 90 ) {
cout << "A-" << endl << endl;
}
else if ( total >= 88 ) {
cout << "B+" << endl << endl;
}
else if ( total >= 82 ) {
cout << "B" << endl << endl;
}
else if ( total >= 80 ) {
cout << "B-" << endl << endl;
}
else if ( total >= 78 ) {
cout << "C+" << endl << endl;
}
else if ( total >= 72 ) {
cout << "C" << endl << endl;
}
else if ( total >= 70 ) {
cout << "C-" << endl << endl;
}
else if ( total >= 68 ) {
cout << "D+" << endl << endl;
}
else if ( total >= 63 ) {
cout << "D" << endl << endl;
}
else if ( total >= 60 ) {
cout << "D-" << endl << endl;
}
else if ( total <= 59 ) {
cout << "F" << endl << endl;
}


// End of main program


cout << endl;
system ("pause");
return 0;
}

Recommended Answers

All 5 Replies

Member Avatar for iamthwee

>How would I go about extracting the best 10 homeworks out of the 12 that are entered??

Sort them, then select the first ten, or last ten depending on what order you sorted them to begin with first.

Sorting eh??

Ok I'll see what I can find. Thanks for the help!!

Member Avatar for iamthwee

You will need to use arrays, and probably use a sort procedure such as bubble sort.

[search]bubble sort c++[/search]

Thanks for pointing me in the right direction. I'll post back when I solve the problem.

Thanks again iamthwee.

I was able to get the bubble sort to work. Thanks for the suggestion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.