Question: C++ 13.1 Adding 5 Numbers Problem: Get Five Numbers Write program to read the users input between 1 and 10(1 < value < 10) The

C++

13.1 Adding 5 Numbers

Problem: Get Five Numbers

Write program to read the users input between 1 and 10(1 < value < 10) The aim is to get 5 valid integers from the user and add them together. If the inputs are not integer type or the integer is out of bound, the program will remind users to read the value again and it will not affect the total five attempts. After reading 5 times integers (whose value is greater than 1 and less than 10), the program will display two messages, one is for how many times of wrong types(ex. Floating, char, string) has been enter, and the other is for the sum of those 5 valid integers.

Example Output:

Enter your input:0

out of bound

Enter your input:0

out of bound

Enter your input:0

out of bound

Enter your input:a

invalid input

Enter your input:a

invalid input

Enter your input:a

invalid input

Enter your input:1

out of bound

Enter your input:2

The number you entered [2] is integer and valid

You have 4 tries left

Enter your input:3

The number you entered [3] is integer and valid

You have 3 tries left

Enter your input:4

The number you entered [4] is integer and valid

You have 2 tries left

Enter your input:5

The number you entered [5] is integer and valid

You have 1 tries left

Enter your input:1

out of bound

Enter your input:2

The number you entered [2] is integer and valid

Congrats! Collect 5 valid integers successfully! (with 3 times wrong type)

The sum of values you entered: 16

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!