| | |
Homework Help
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 13
Reputation:
Solved Threads: 0
Okay I'm gonna be honest with you... I have no idea what I'm doing... no not even a little. I'm in an online C++ class that I'm only taking because it was the last required course for me to graduate this semester... This is the last assignment due and I honestly haven't got a clue where to start... The last assignments I did seemed fairly simple with a little research but this one has completely thrown me off.
If anyone felt like helping me out... or getting me started that'd be great and I'd love you forever. =P I was helped here before and I realize that you're kinda supposed to at least have a basis program or something... I promise you it's not that I'm trying to get anyone to just do my homework for me... I've stared long and hard at this trying to figure out what I should do first... =[ Help?
Here's the assignment:
Write a program that will read student names and percentage grades from the keyboard and then sort them (highest grade first) and calculate average, lowest and highest grade as shown below:
Example :
>How many students do you want to process?
4
>Enter name for student #1 :
JONES
>Enter grade for student #1 :
60
>Enter name for student #2 :
SMITH
>Enter grade for student #2 :
80
>Enter name for student #3
FORSTER:
>Enter grade for student #3 :
55
>Enter name for student #4 :
ALAZAR
>Enter grade for student #4 :
85
>====================
>CLASS GRADE REPORT :
>____________________
>ALAZAR B
>SMITH B
>JONES D
>FORSTER F
>_____________________
>HIGHEST GRADE : 80.00
>LOWEST GRADE : 55.00
>AVERAGE : 70.00
>=====================
If anyone felt like helping me out... or getting me started that'd be great and I'd love you forever. =P I was helped here before and I realize that you're kinda supposed to at least have a basis program or something... I promise you it's not that I'm trying to get anyone to just do my homework for me... I've stared long and hard at this trying to figure out what I should do first... =[ Help?
Here's the assignment:
Write a program that will read student names and percentage grades from the keyboard and then sort them (highest grade first) and calculate average, lowest and highest grade as shown below:
Example :
>How many students do you want to process?
4
>Enter name for student #1 :
JONES
>Enter grade for student #1 :
60
>Enter name for student #2 :
SMITH
>Enter grade for student #2 :
80
>Enter name for student #3
FORSTER:
>Enter grade for student #3 :
55
>Enter name for student #4 :
ALAZAR
>Enter grade for student #4 :
85
>====================
>CLASS GRADE REPORT :
>____________________
>ALAZAR B
>SMITH B
>JONES D
>FORSTER F
>_____________________
>HIGHEST GRADE : 80.00
>LOWEST GRADE : 55.00
>AVERAGE : 70.00
>=====================
•
•
Join Date: Mar 2008
Posts: 42
Reputation:
Solved Threads: 6
I have finished it, but to don't violate the rules of this website --"Don't give away code" , I can not give you all my source code. The following is the framework of program. hope it can help you.
c++ Syntax (Toggle Plain Text)
#include <iostream> #include <vector> using namespace std; struct Student { string name; float grade; }; char convert(float grade) { if (grade >= 90) return 'A'; if ( grade >= 80) return 'B'; ....... } void sortStudents(vector<Student>& students) { } float getAverage(const vector<Student>& students) { int size = students.size(); float total = 0.0; for (int i=0; i<size; ++i) { ............... } return total / size; } void display(const vector<Student>& students) { cout<<"===================="<<endl; cout<<"CLASS GRADE REPORT :"<<endl; cout<<"____________________"<<endl; int size = students.size(); for (int i=0; i<size; ++i) { cout<<students[i].name<<"\t"<<convert(students[i].grade)<<endl; } cout<<"_____________________"<<endl; cout<<"HIGHEST GRADE : "<<students[0].grade<<endl; cout<<"LOWEST GRADE : "<<students[students.size() -1].grade<<endl; cout<<"AVERAGE : "<<getAverage(students)<<endl; cout<<"====================="<<endl; } int main() { int number; vector<Student> students; cout<<"How many students do you want to process?"<<endl; cin>>number; for (int i=0; i<number; ++i) { Student temp; //deal with the input and then construct the struct 'temp' students.push_back(temp); } sortStudents(students); display(students); system("PAUSE"); return 0; }
Last edited by littlestone; Apr 25th, 2008 at 3:34 am.
![]() |
Similar Threads
- We only give homework help to those who show effort (Computer Science)
- Need help with Computer Science homework (Computer Science)
- Dynamic memory allocation homework (C++)
- Homework Help!! Priority Queue ?? (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: Emty a 2D vector
- Next Thread: DLL problem in Borland C++
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap bmp c++ c/c++ calculator char class classes code compile compiler console conversion count delete desktop directshow dll download dynamic encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib library linkedlist linker linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct studio temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





