Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ code 5.14 Custom Lab: Loops (while)**: Running Calculations Compute the average of a list of user-entered integers representing rolls of two dice. The list
C++ code
5.14 Custom Lab: Loops (while)**: Running Calculations Compute the average of a list of user-entered integers representing rolls of two dice. The list ends when 0 is entered. Integers must be in the range 2 to 12 (inclusive); integers outside the range don't contribute to the average. Output the average, and the number of valid and invalid integers (excluding the ending 0 ). If only 0 is entered, output 0 . The output may be a floating-point value. Ex: If the user enters 812 130 , the output is: Average: 10 Vaild: 2 Invalid: 1 HINTS - Use a while loop with expression (userInt != 0) - Read the user's input into userint before the loop, and also at the end of the loop body - In the loop body, use an if-else to distinguish integers in the range and integers outside the range - For integers in the range, keep track of the sum, and number of integers. For integers outside the range, just keep track of the number. - Use a static cast to get a floating-point output (static_cast (sum)) / num - Whenever dividing, be sure to handle the case of the denominator being 0 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