Question: Flowchart & pseudocode & nassi-schneiderman 1. The input to the problem has an unknown quantity of integers, each integer comes in separately. The input has
Flowchart & pseudocode & nassi-schneiderman




1. The input to the problem has an unknown quantity of integers, each integer comes in separately. The input has a sentinel value of 0. The o marks the end of the input and is not to be considered part of the input. The output must be the average of the even numbers in the input. If there are no even numbers, an error message should be printed. Example sequence of events: - Let's say the input is 12340. Before the program starts to read the input, it will set the total and count variable to 0. The program will read 1. This is not an even number, so it is not used in the average calculation. - total = 0, count = 0 The program then reads a 2. Since this is even, it will add the number to total and increment count. - total = 2, count = 1 The program will read 3. This is not an even number, so it is not used in the average calculation. - total = 2, count = 1 The program then reads a 4. Since this is even, it will add the number to total and increment count - total = 6, count = 2 The program then reads a 0. This indicates the end of the sequence of integers, so it will now calculate the average of all the even numbers. - average = total / count = 6/2 = 3 a. Fill in the "???" parts of the flowchart. Start total = 0 count = 0 Read input No ??? -No input % 2 == 0 Yes total = ??? count = ??? Yes ??? -???- print total/count ??? print error message End b. Fill in the "???" parts of the pseudo-code for this problem. total = 0 count = 0 read input while (???) if (???) total = ??? count = ??? end if read input end while if(???) print error message else print total / count end if c. Fill in the "???" part of the Nassi-Schneiderman diagram for this problem. set total = 0 and count = 0 read input while ??? ??? yes no total = ??? count = ??? read input ??? yes no print error message print total / count
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
