-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaverage.cpp
More file actions
28 lines (25 loc) · 1.03 KB
/
Copy pathaverage.cpp
File metadata and controls
28 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*********************************************************************
** Author: Jordan Hamilton
** Date: 01/16/2018
** Description: This program prompts the user to input five numbers,
** calculates the average, then outputs the result to the screen.
*********************************************************************/
#include <iostream>
int main()
{
// Define variables prior to user input
double inputNumber1, inputNumber2, inputNumber3, inputNumber4, inputNumber5, average;
// Prompt for number entry
std::cout << "Please enter five numbers." << std::endl;
std::cin >> inputNumber1;
std::cin >> inputNumber2;
std::cin >> inputNumber3;
std::cin >> inputNumber4;
std::cin >> inputNumber5;
// Calculate the average of the entered numbers
average = (inputNumber1 + inputNumber2 + inputNumber3 + inputNumber4 + inputNumber5) / 5;
// Display the calculated average to the user
std::cout << "The average of those numbers is:" << std::endl;
std::cout << average << std::endl;
return 0;
}