fork download
  1. //Castulo Jason Quintero CSC5 Chapter 3, P. 143, #3
  2. //
  3. /**************************************************************
  4.  *
  5.  * Compute Average Test Score
  6.  * ____________________________________________________________
  7.  * This program compute average score on the test.
  8.  *
  9.  * Computation is based on the formula:
  10.  * sumTestScores = testscore1 + testscore2 + testscore3 + testscore4 + testscore5
  11.  * AVG = sumTestScores/5
  12.  * ____________________________________________________________
  13.  * INPUT
  14.  * testscore1
  15.  * testscore2
  16.  * testscore3
  17.  * testscore4
  18.  * testscore5
  19.  *
  20.  * OUTPUT
  21.  * AVG: Average Score on Test
  22.  *
  23.  **************************************************************/
  24. #include <iostream>
  25. #include <iomanip>
  26. using namespace std;
  27.  
  28. int main() {
  29. // Variables
  30. float testscore1;
  31. float testscore2;
  32. float testscore3;
  33. float testscore4;
  34. float testscore5;
  35. float sumTestScores;
  36. float AVG;
  37. //Input
  38. cout << "Enter the following five test scores." <<endl;
  39. cin >> testscore1;
  40. cin >> testscore2;
  41. cin >> testscore3;
  42. cin >> testscore4;
  43. cin >> testscore5;
  44. // Compute
  45. sumTestScores = testscore1 + testscore2 + testscore3 + testscore4 + testscore5;
  46. AVG = sumTestScores/5;
  47. // Output
  48. cout << fixed << setprecision(1) << AVG << endl;
  49. return 0;
  50. }
Success #stdin #stdout 0.01s 5304KB
stdin
87
65
93
48
86
stdout
Enter the following five test scores
75.8