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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started