Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please see both pictures and answer proper code from start to end 1. Even though I suggest you plan for what you are aleout to
please see both pictures and answer proper code from start to end
1. Even though I suggest you plan for what you are aleout to do. I am not requiring udocode for this lab because I have given you most f the program AND pseu pseu docodel 2. Adapt the concepts shown in the IOArg demos to provide a programi which faithfully s a list of non-negative integer scores, ultimately teriminating the list reading when the sentinel value (lets use -9999) is entered. The program should then correctly report the number of non-negative scores entered and the arithmetic mean (average of those scores (an accurate floating point or decimal- valued average, please. No, it does NOT need 15 places, the default is ftine) 3. Demonstrate your programs behavior in response to errors on input (that show that it faithfully rejects improper input such as alphabetic characters. decimal points and commas). Here are some specifie exarmples dermonstrating the requirernents of your program (a) I'll compute the average of your impu 10, 20 35 50.5 -9999 Results: 5 non-negative integers entered, awrage 2 // KB Comment: the non-negative intagers peaudl were (1o 20, 35, 50,5) (b) I'll compute the average of your inputs 5 -10 25.40, -9999 Results: 3 non-negative integers ent // KB Comment: the non-negative intregers read wam ered, avernge 23,3333 With F 25. 40) (c) I'll compute the average of your inputs 30 45 -9 one junk 100.0 more -10008-9909 Results: 5 non-negative integers entered, average 36 // KB Comment: the non-n s read were (30, 45, 100, o, 4. Here is a pseudo-code version to consider for implementing this task: Initialize a Sum and Counter to zero Initialize a loop Done variable to false', or zero Provide a brief console output to describe uhat the program will do While not Done Attempt to read the nert Input, checking for an integer read failure If this attempt to read an integer failed then Clear the input stream status, then ign0e the current charcter on the stream Repeat the attempt to iead an integer until successful Set the loop Done variable to true', or nonzero Add one to the Counter If the Input integer is the sentinel value Else if the Input integer is non-negative then Add the Input to the Sum Repeat until Done Compute and display the number of inputs and the average (report O average for 0 inputs)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