Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an intelligent C++ program to process the commands like these. add up numbers 10 56 12 also 89 and output the total give me

Write an intelligent C++ program to process the commands like these.

add up numbers 10 56 12 also 89 and output the total give me the average of 80 and all these 85 90 92 56 what is the max of 56 12 98 56 23 12 98 find the min among 34 98 24 76 100 11.1 22.2 33.3 44.4 total these numbers tell me the purpose of life ok that is enough bye 

OK, let us simplify the requirements :-) Write a program to read the input lines and process them. End the program when current line has a word "bye". After reading each line, find the total, average, min and max of all the numbers in the line. Also, look for the following key words: total, average, min & max. You can ignore all other words. So, here is the output for the sample input given above.

10 56 12 89 total 167 80 85 90 92 56 average 80.6 56 12 98 56 23 12 98 max 98 34 98 24 76 100 min 24 11.1 22.2 33.3 44.4 total 111 tell me the purpose of life - I am not yet that smart to answer this one! OK bye! 

Here is the pseudocode/code for the core logic.

//read a line while (getline(cin, line)) { istringstream lineInput(line); string word; //get one word at a time! while (lineInput >> word) { double value; //is the word number or string? if (istringstream(word) >> value) //number! else //string!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

What are negative messages? (Objective 1)

Answered: 1 week ago