943,733 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 694
  • C++ RSS
Apr 25th, 2008
0

Homework Help

Expand Post »
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
>=====================
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jennyebrooke is offline Offline
13 posts
since Apr 2008
Apr 25th, 2008
1

Re: Homework Help

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)
  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.
Reputation Points: 14
Solved Threads: 6
Light Poster
littlestone is offline Offline
42 posts
since Mar 2008
Apr 25th, 2008
0

Re: Homework Help

OMG I LOVE YOU! lol no really you're absolutely amazing! You pretty much saved me from not graduating this semester lol

<3333
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jennyebrooke is offline Offline
13 posts
since Apr 2008
Apr 25th, 2008
0

Re: Homework Help

kindly reminder, the sort function I posted don't work correctly, you should correct it by yourself.
Reputation Points: 14
Solved Threads: 6
Light Poster
littlestone is offline Offline
42 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Emty a 2D vector
Next Thread in C++ Forum Timeline: DLL problem in Borland C++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC