fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double result;
  5. double number1;
  6. double number2;
  7. double number3;
  8. double number4;
  9. double number5;
  10. string firstname;
  11. string lastname;
  12.  
  13. int main()
  14. {
  15. cout<<endl;
  16. cout<<"Enter student's first name: ";
  17. cin>>firstname;
  18. cout<<"Enter student's last name: ";
  19. cin>>lastname;
  20. cout<<"Enter a score for the first test: ";
  21. cin>>number1;
  22. cout<<"Enter a score for the second test: ";
  23. cin>>number2;
  24. cout<<"Enter a score for the third test; ";
  25. cin>>number3
  26. cout<<"Enter a score for the fourth test: ";
  27. cin>>number4;
  28. cout<<"Enter a score for the fifth test: ";
  29. cin>>number5;
  30. cout<<endl;
  31.  
  32. cout<<"Your entered the following scores for student name "<<firstname<<" "<<lastname<<": "<<number1<<", "<<number2<<", "<<number3<<", "<<number4<<", and "<<number5<<". "<<endl;
  33. result = (number1+number2+number3+number4+number5)/5; //process
  34. cout<<endl;
  35.  
  36. cout<<"Student name: "<<firstname<<" "<<lastname<<endl;
  37. cout<<"The Average is: "<<result<<". "<<endl;
  38. cout<<"Your grade is: ";
  39.  
  40. if (result>=90 & result<100)
  41. {
  42. cout<<"A"<<endl;
  43. }
  44. if (result>=80 & result<90)
  45. {
  46. cout<<"B"<<endl;
  47. }
  48. if (result>=70 & result<80)
  49. {
  50. cout<<"C"<<endl;
  51. }
  52. if (result>=65 & result<70)
  53. {
  54. cout<<"D"<<endl;
  55. }
  56. if (result<=65)
  57. {
  58. cout<<"F"<<endl;
  59. }
  60. if (result>=97 & result<100)
  61. {
  62. cout<<"Your GPA is 4.0"<<endl;
  63. }
  64. if (result>=93 & result<96)
  65. {
  66. cout<<"Your GPA is 4.0"<<endl;
  67. }
  68. if (result>=90 & result<92)
  69. {
  70. cout<<"Your GPA is 3.7"<<endl;
  71. }
  72. if (result>=87 & result<89)
  73. {
  74. cout<<"Your GPA is 3.3"<<endl;
  75. }
  76. if (result>=83 & result<86)
  77. {
  78. cout<<"Your GPA is 3.0"<<endl;
  79. }
  80. if (result>=80 & result<82)
  81. {
  82. cout<<"Your GPA is 2.7"<<endl;
  83. }
  84. if (result>=77 & result<79)
  85. {
  86. cout<<"Your GPA is 2.3"<<endl;
  87. }
  88. if (result>=73 & result<76)
  89. {
  90. cout<<"Your GPA is 2.0"<<endl;
  91. }
  92. if (result>=70 & result<72)
  93. {
  94. cout<<"Your GPA is 1.7"<<endl;
  95. }
  96. if (result>=67 & result<69)
  97. {
  98. cout<<"Your GPA is 1.3"<<endl;
  99. }
  100. if (result>=65 & result <66)
  101.  
  102. {
  103. cout<<"Your GPA is 1.0"<<endl;
  104. }
  105. if (result<65)
  106. {
  107. cout<<"Your GPA is 0.0"
  108. }
  109. return 0;
  110. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:26:5: error: expected ‘;’ before ‘cout’
     cout<<"Enter a score for the fourth test: ";
     ^
prog.cpp:40:11: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
 if (result>=90 & result<100)
           ^
prog.cpp:44:11: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
 if (result>=80 & result<90)
           ^
prog.cpp:48:11: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
 if (result>=70 & result<80)
           ^
prog.cpp:52:11: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
 if (result>=65 & result<70)
           ^
prog.cpp:60:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=97 & result<100)
               ^
prog.cpp:64:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=93 & result<96)
               ^
prog.cpp:68:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=90 & result<92)
               ^
prog.cpp:72:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=87 & result<89)
               ^
prog.cpp:76:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=83 & result<86)
               ^
prog.cpp:80:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=80 & result<82)
               ^
prog.cpp:84:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=77 & result<79)
               ^
prog.cpp:88:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=73 & result<76)
               ^
prog.cpp:92:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=70 & result<72)
               ^
prog.cpp:96:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=67 & result<69)
               ^
prog.cpp:100:15: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
     if (result>=65 & result <66)
               ^
prog.cpp:108:1: error: expected ‘;’ before ‘}’ token
 }
 ^
stdout
Standard output is empty