Write a program that does the following:
a. Prompts the user to input five decimal numbers.
b. Prints the five decimal numbers.
c. Converts each decimal number to the nearest integer.
d. Adds the five integers.
e. Prints the sum and average of the five integers.
Code:
#include <iostream>
using namespace std;
int main()
{
double num1, num2, num3, num4, num5;
cout << "Please enter 5 decimal numbers: \n";
cin >> num1 >> num2 >> num3 >> num4 >> num5;
double result = num1 + num2 + num3 + num4 + num5;
cout << "The sum of all the numbers is: " << static_cast<int>(result) << endl;
cout << "\nThe average of all the numbers is: " << (static_cast<int>(result)/5) << endl;
return 0;
}