fork download
  1. //Eesha Tangirala #CS1A Chapter 3, pg. 143, #3
  2.  
  3. //*****************************************************************************
  4.  
  5. //Calculate Test Average
  6. //_____________________________________________________________________________
  7. //This program computes the average of test scores for five scores given.
  8. //_____________________________________________________________________________
  9.  
  10. //INPUT
  11. //Five Test Scores
  12.  
  13. //OUTPUT
  14. //Test Score Average
  15.  
  16. //*******************************************************************************
  17.  
  18. #include <iostream>
  19. #include <iomanip>
  20. using namespace std;
  21.  
  22. int main() {
  23. //Data Dictionary
  24. //5 Test Scores Given
  25. float x;
  26. float y;
  27. float z;
  28. float b;
  29. float a;
  30.  
  31. //Input
  32. cout << "What are five test scores earned?" << endl;
  33. cin >> x >> y >> z >> b >> a;
  34.  
  35. //Calculate Test Score Average
  36. float average = (x+y+z+b+a)/5;
  37.  
  38. //Output Result
  39. cout << "The average of the five test scores is " << fixed << setprecision(1) << average << endl;
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0.01s 5284KB
stdin
33.5 66.7 99.9 100 87.2
stdout
What are five test scores earned?
The average of the five test scores is 77.5