fork download
  1. /******************************************************************************
  2.  * AUTHOR : Aiden Stannard *
  3.  * STUDENT ID : 1284603 *
  4.  * Ch3, p143, #3 : Test Average *
  5.  * CLASS : CS1A *
  6.  * SECTION : T/Th 6PM - 8:20PM *
  7.  * DUE DATE : 9/12/2026 *
  8.  ******************************************************************************/
  9. /******************************************************************************
  10.  * CALCULATE Average Test Score
  11.  * ____________________________________________________________________________
  12.  * This program Calculates the Average test score out of fives test scores using
  13.  * by requesting the user to enter the scores one After the other, and than displaying
  14.  * the Average
  15.  *
  16.  * Computation is based on the formula: (Test + Test + Test + Test + Test) / 5
  17.  * ____________________________________________________________________________
  18.  * INPUT
  19.  * Enter the test scores for each one of your tests and press enter for every
  20.  * score youve entered:___
  21.  *
  22.  *OUTPUT
  23.  * Your Test Average was:___
  24.  *
  25.  ******************************************************************************/
  26. #include <iostream>
  27. #include <iomanip>
  28. using namespace std;
  29.  
  30. int main() {
  31.  
  32. float test1, test2, test3, test4, test5; // All fives test scores
  33. float testAverage; // Test score average after computation
  34.  
  35. cout << "Enter the test scores for each one of your tests and press enter for every score youve entered:\n";
  36. cin >> test1 >> test2 >> test3 >> test4 >> test5;
  37. testAverage = (test1 + test2 + test3 + test4 + test5) / 5;
  38. cout << setprecision(1) << fixed << "Your Test Average was: " << testAverage;
  39. return 0;
  40. }
Success #stdin #stdout 0s 5312KB
stdin
50
50
50
50
50
stdout
Enter the test scores for each one of your tests and press enter for every score youve entered:
Your Test Average was: 50.0