Homework Help

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2008
Posts: 13
Reputation: jennyebrooke is an unknown quantity at this point 
Solved Threads: 0
jennyebrooke jennyebrooke is offline Offline
Newbie Poster

Homework Help

 
0
  #1
Apr 25th, 2008
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
>=====================
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 42
Reputation: littlestone is an unknown quantity at this point 
Solved Threads: 6
littlestone littlestone is offline Offline
Light Poster

Re: Homework Help

 
1
  #2
Apr 25th, 2008
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.

  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. struct Student
  7. {
  8. string name;
  9. float grade;
  10. };
  11.  
  12. char convert(float grade)
  13. {
  14. if (grade >= 90)
  15. return 'A';
  16.  
  17. if ( grade >= 80)
  18. return 'B';
  19. .......
  20. }
  21.  
  22. void sortStudents(vector<Student>& students)
  23. {
  24.  
  25. }
  26.  
  27. float getAverage(const vector<Student>& students)
  28. {
  29. int size = students.size();
  30. float total = 0.0;
  31.  
  32. for (int i=0; i<size; ++i)
  33. {
  34. ...............
  35. }
  36.  
  37. return total / size;
  38. }
  39.  
  40. void display(const vector<Student>& students)
  41. {
  42. cout<<"===================="<<endl;
  43. cout<<"CLASS GRADE REPORT :"<<endl;
  44. cout<<"____________________"<<endl;
  45.  
  46. int size = students.size();
  47. for (int i=0; i<size; ++i)
  48. {
  49. cout<<students[i].name<<"\t"<<convert(students[i].grade)<<endl;
  50. }
  51.  
  52. cout<<"_____________________"<<endl;
  53. cout<<"HIGHEST GRADE : "<<students[0].grade<<endl;
  54. cout<<"LOWEST GRADE : "<<students[students.size() -1].grade<<endl;
  55. cout<<"AVERAGE : "<<getAverage(students)<<endl;
  56. cout<<"====================="<<endl;
  57. }
  58.  
  59. int main()
  60. {
  61. int number;
  62. vector<Student> students;
  63. cout<<"How many students do you want to process?"<<endl;
  64. cin>>number;
  65.  
  66. for (int i=0; i<number; ++i)
  67. {
  68. Student temp;
  69. //deal with the input and then construct the struct 'temp'
  70.  
  71. students.push_back(temp);
  72. }
  73.  
  74. sortStudents(students);
  75.  
  76. display(students);
  77.  
  78. system("PAUSE");
  79. return 0;
  80. }
Last edited by littlestone; Apr 25th, 2008 at 3:34 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 13
Reputation: jennyebrooke is an unknown quantity at this point 
Solved Threads: 0
jennyebrooke jennyebrooke is offline Offline
Newbie Poster

Re: Homework Help

 
0
  #3
Apr 25th, 2008
OMG I LOVE YOU! lol no really you're absolutely amazing! You pretty much saved me from not graduating this semester lol

<3333
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 42
Reputation: littlestone is an unknown quantity at this point 
Solved Threads: 6
littlestone littlestone is offline Offline
Light Poster

Re: Homework Help

 
0
  #4
Apr 25th, 2008
kindly reminder, the sort function I posted don't work correctly, you should correct it by yourself.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC