fork download
  1. // Gage Alvarez CS1A Chapter 3 P.186, #3
  2.  
  3. /**************************************************************
  4.  *
  5.  * Calculating test average
  6.  * ____________________________________________________________
  7.  * Description
  8.  * This program Calculates the average score of 5 tests
  9.  * ____________________________________________________________
  10.  * INPUT
  11.  * test1: the score of test 1
  12.  * test2: the score of test 2
  13.  * test3: the score of test 3
  14.  * test4: the score of test 4
  15.  * test5: the score of test 5
  16.  * OUTPUT
  17.  * average: the average of the scores
  18.  *
  19.  **************************************************************/
  20.  
  21. #include <iostream>
  22.  
  23. int main() {
  24. float test1;
  25. float test2;
  26. float test3;
  27. float test4;
  28. float test5;
  29. float average;
  30.  
  31. std::cin >> test1 >> test2 >> test3 >> test4 >>test5;
  32. average = (1.0* test1 + test2 + test3 + test4 + test5)/ 5;
  33. std::cout << "The average score for all tests is " << average;
  34. }
Success #stdin #stdout 0s 5308KB
stdin
98 54 79 99 86
stdout
The average score for all tests is 83.2