Question: For this assignment you are to implement a program that processes a sequence of values input by a user, and generates and outputs the following

For this assignment you are to implement a program that processes a sequence of values input by a user, and generates and outputs the following results: The sum of the input values The sum of the even numbers input The sum of the odd number input The sum of the numbers that are neither even or odd The average of all of the input values The program should begin by prompting the user to input a value. This value can be any real number. Once this value has been processed, the program should then ask the user if there is another value to be processed. Each time the the user responds in the affirmative, by inputting Y or y, the program should prompt the user to input another value, process that value, and then ask again if there is another value to process. Once the user responds in the negative by inputting a value other than Y or y, the program should output the generated results (as listed above) and terminate. Your assignment submission should include two document: one a text-based file (e.g., .cpp extension) that contains a copy of your code, and the other a copy of the output generated by your program using the data that I supply. On the following page is a copy of the output generated by my implementation of the assignment using the following data values: 10, 1.2, 7.0, 3.8, 20.0

Output Generated by My Implementation of the Assignment Enter a value to be processed: 10 Do you have another value to be processed? (Y/N): Y Enter a value to be processed: 1.2 Do you have another value to be processed? (Y/N): y Enter a value to be processed: 7.0 Do you have another value to be processed? (Y/N): Y Enter a value to be processed: 3.8 Do you have another value to be processed? (Y/N): y Enter a value to be processed: 20.0 Do you have another value to be processed? (Y/N): n The sum of input values: 42 The sum of even input values: 30 The sum of odd input values: 7 The sum of non-even/non-odd input values: 5 The average of the input values: 8.4 Thank you for using this program C:\Users\user\Documents\code\program 1\Debug\program 1.exe(process 5964) exited with code 0. Press any key to close this window . . .

this is what I have:

#include

using namespace std;

int main() { int value; int values; int totalSum, average; int oddSum=0; int evenSum=0; char again = 'Y';

while (again == 'Y' || again == 'y') { //Prompts user to enter values cout << " Enter a value to be processed: "; cin >> value; totalSum += value; values += 1; average = (totalSum / values); if (value%2==0) evenSum += value; cout << "Do you have another value to be processed? (Y/N) "; cin >> again; } //Outputs sum of all values cout<<" The sum of the input values is " << totalSum << "." <

//Outputs sum of even values cout << " The sum of the even input values is " << evenSum << "." <

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!