Exam 3 Part IIb Take Home Section: Name: ___________________________

Use Modular Programming to create the Defining Diagram, the Hierarchy Chart, and the Pseudo Code for the three problems listed below:

You must type your solutions. This includes the Defining Diagram, the Hierarchy Chart, and the Pseudo Code. No exam will be accepted unless typed.

A. Defining Diagram Example:

Inputs Processing Output

B. Hierarchy chart Example:

C. Pseudo Code (Not C++ code) No credit given for statements with C++ code or syntax.

1. The following algorithms involve the simple manipulation of Arrays. Each algorithm should be designed using a For loop. The Array in each algorithm is named ArrayA[SIZE] and the subscript is named index. SIZE represents the number of elements in the array. Design an algorithm using modular programming that will Perform the following functions on a 1-dimensional array. Your program will accept the values for a one-dimensional array and an operation code to perform the following functions:

a) Find the sum of the elements of the array. You will add the elements and store the result in a variable called sum, then print the result to the terminal.

b) Find the Mean (average) of the elements of the array. You will add the elements and store the result in a variable called sum, then divide the result by the number of elements and print the result.

c) Find the largest of the elements of the array. You will search the array to obtain the largest value and store in a variable called largestElement, then print the largestElement.

d) Find the smallest of the elements of the array. You will search the array to obtain the smallest value and store in a variable called smallestElement, then print the smallestElement.

e) Find the range of the elements of an array. You will search the array to obtain the smallest and the largest element. Hint! Start by setting smallest and largest equal to the first element in the array. Then search for a smaller or larger value. At the end print both smallest and largest as the range.

Your algorithm will print an error message if an invalid operation code is entered, and an End of Program message should be printed at the end. The program will continuously accept numbers and an operation code until 0 is inputted for the operation code.

2. Create the logic for a program using modular programming that continuously prompts the user for two numeric values that represent the dimensions of a room in feet. Include two overloaded methods that compute the room’s area. One method takes two numeric parameters and calculates the area by multiplying the parameters. The other takes a single numeric parameter, which is squared to calculate area. Each method displays its calculated result. Accept input and respond as follows:

• When the user enters zero for the first value, end the program.

• If the user enters a negative number for either value, continue to re-prompt the user until the value is not negative.

• If both numbers entered are greater than 0, call the method version that accepts two parameters and pass it both values.

• If the second value is zero, call the version of the method that accepts just one parameter and pass it the nonzero value.

3. a. Professor Zak allows students to drop the three lowest scores on the ten 100-point quizzes she gives during the semester. Design an application that accepts a student name and ten quiz scores. Output the student’s name and total points for the student’s six highest-scoring quizzes.

b. Modify the application in Exercise 3a so that the student’s mean and median scores on the six best quizzes are displayed.

Use the following flow charts to assist you with these problems:

Flowchart: Part a

b. Modify the application in Exercise 3a so that the student’s mean and median scores on the six best quizzes are displayed.

Flowchart: Part b