fork download
  1. //OrinTill Qimid CS1A Chapter 3, P. 143, #3
  2. //
  3. /**************************************************************
  4.  *
  5.  * Calculate average.
  6.  * ____________________________________________________________
  7.  * This program is going to calcuate the average of 5 given test scores.
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * test1 : the score of test 1
  11.  * test2 : the score of test 2
  12.  * test3 : the score of test 3
  13.  * test4 : the score of test 4
  14.  * test5 : the score of test 5
  15.  * OUTPUT
  16.  * Total : The calculated average base on the 5 test
  17.  *
  18.  **************************************************************/
  19. #include <iostream>
  20. #include <iomanip>
  21. #include <cmath>
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26. float test1, //Declearing the 5 test score and the total.
  27. test2,
  28. test3,
  29. test4,
  30. test5,
  31. total;
  32. cout <<"What is your score on test 1." << endl;
  33. cin >> test1;
  34. cout <<"What is your score on test 2." << endl;
  35. cin >> test2;
  36. cout <<"What is your score on test 3." << endl;
  37. cin >> test3;
  38. cout <<"What is your score on test 4." << endl;
  39. cin >> test4;
  40. cout <<"What is your score on test 5." << endl;
  41. cin >> test5;
  42. total = (test1 + test2 + test3 + test4 + test5)/5;
  43. cout<< "Your average test score is going to be " << total << endl;
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5292KB
stdin
1
2
3
4
5
stdout
What is your score on test 1.
What is your score on test 2.
What is your score on test 3.
What is your score on test 4.
What is your score on test 5.
Your average test score is going to be 3