# Answer to Question #27223 in C++ for Mehmil Khan

Question #27223

Question 6: Write a Program that prompts the user to input five decimal numbers in one Line Separated with Space. The program should then add the five decimal numbers, convert the sum to the nearest integer, and print the result (5 points)

Sample Output

Enter the Five Decimal Numbers: 25 3.4 68.3 9 4.1

The Sum of these Decimal Numbers is = 109.8

Number Round to = 110

Sample Output

Enter the Five Decimal Numbers: 25 3.4 68.3 9 4.1

The Sum of these Decimal Numbers is = 109.8

Number Round to = 110

Expert's answer

#include <iostream>

#include <string>

#include <conio.h>

using namespace std;

//main function

int main()

{

string FivedecimalNumbers;//input numbers

double Sum=0;//variable for sum

int NumberRound;

cout<<"Enter the Five Decimal Numbers: ";

cin >> FivedecimalNumbers;//input FivedecimalNumbers

//calculate sum

for(int i=0;i<FivedecimalNumbers.length();i++){

Sum+=(double)FivedecimalNumbers[i];

}

//show rsult

cout<<"The Sum of these Decimal Numbers is = "<<Sum;

NumberRound=(int)Sum;

cout<<"Number Round to = "<<NumberRound;//show Number

Round

getch();

return 0;

}

#include <string>

#include <conio.h>

using namespace std;

//main function

int main()

{

string FivedecimalNumbers;//input numbers

double Sum=0;//variable for sum

int NumberRound;

cout<<"Enter the Five Decimal Numbers: ";

cin >> FivedecimalNumbers;//input FivedecimalNumbers

//calculate sum

for(int i=0;i<FivedecimalNumbers.length();i++){

Sum+=(double)FivedecimalNumbers[i];

}

//show rsult

cout<<"The Sum of these Decimal Numbers is = "<<Sum;

NumberRound=(int)Sum;

cout<<"Number Round to = "<<NumberRound;//show Number

Round

getch();

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment