fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 294, 4
  2. //
  3. /**************************************************************
  4.  * CALCULATE GRADE
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will calculate a letter grade for each students
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * name : name of the students.
  11.  * score : score for each students.
  12.  * OUTPUT
  13.  * grade : grade for each students
  14.  **************************************************************/
  15. #include <iostream>
  16. #include <iomanip>
  17. #include <cmath>
  18. using namespace std;
  19.  
  20.  
  21.  
  22. int main()
  23. {
  24.  
  25. string names [5];
  26. string grade [5];
  27. double score [5];
  28. for (int i = 0; i < 5; i++)
  29. {
  30.  
  31. cout<<"please enter name for student"<<endl;
  32. cin>>names[i];
  33. cout<<"please enter score for student "<<names[i]<<endl;
  34. cin>>score[i];
  35. if (score[i]>=90)
  36. {
  37. grade[i] = 'A';
  38.  
  39.  
  40. }
  41. else if (score[i]>=80)
  42. {
  43. grade[i] = 'B';
  44. }
  45. else if (score[i]>=70)
  46. {
  47. grade[i] = 'C';
  48. }
  49. else if (score[i]>=60)
  50. {
  51. grade[i] = 'D';
  52. }
  53. else
  54. {
  55. grade [i] = 'F';
  56. }
  57.  
  58. }
  59. for (int s = 0; s < 5; s++)
  60. {
  61. cout<<"Grade for student "<<names[s]<<endl;
  62. cout<<grade[s]<<endl;
  63.  
  64. }
  65.  
  66.  
  67.  
  68. return 0;
  69. }
  70.  
  71.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty