fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. double score1, score2, score3, score4, score5;
  8. double average;
  9.  
  10. // Get user input
  11. cout << "Insert your score for first test\n";
  12. cin >> score1;
  13.  
  14. cout << "Insert your score for second test\n";
  15. cin >> score2;
  16.  
  17. cout << "Insert your score for third test\n";
  18. cin >> score3;
  19.  
  20. cout << "Insert your score for fourth test\n";
  21. cin >> score4;
  22.  
  23. cout << "Insert your score for fifth test\n";
  24. cin >> score5;
  25.  
  26. // Calculate the average score
  27. average = (score1 + score2 + score3 + score4 + score5)/5;
  28.  
  29. // Display the output
  30. cout << fixed << showpoint << setprecision(1);
  31. cout << "First test score = " << setw (5) << score1 << endl;
  32. cout << "Second test score = " << setw (5) << score2 << endl;
  33. cout << "Third test score = " << setw (5) << score3 << endl;
  34. cout << "Fourth test score = " << setw (5) << score4 << endl;
  35. cout << "Fifth test score = " << setw (5) << score5 << endl;
  36. cout << "______________________________\n";
  37. cout << "Average test score = " << setw (5) << average << endl;
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5208KB
stdin
97.9
56
78
90
85
stdout
Insert your score for first test
Insert your score for second test
Insert your score for third test
Insert your score for fourth test
Insert your score for fifth test
First test score   =  97.9
Second test score  =  56.0
Third test score   =  78.0
Fourth test score  =  90.0
Fifth test score   =  85.0
______________________________
Average test score =  81.4