# pseudocode

posted by on .

Assume that your family has 10 members. Assume further that each family member has a certain amount of savings. Your task is to determine: (a) the total amount of savings that the family has, as a whole and (b) to determine who has the largest savings. To solve this problem:

a. Show the pseudocode declarations needed to declare two arrays - one an array which contains the names of the family members, and the other an array which contains the savings (i.e. money) held by each family member. The arrays are parallel arrays because the savings shown in the second array for a certain array position are the savings for the family member whose name appears in the same position in the first array.

b. Write a function, which is called from the main module - this function will determine and return the total savings.

c. Write a function also called from the main module - this function will determine and return the array index containing the largest savings. Your main program should then print the name of the person who holds those savings, as well as the amount

• pseudocode - ,

What have you done so far?

• pseudocode - ,

Pseudocode
Step 1: Take an two dimensional array of character for holding names, another array say sav of float type for holding savings .
Names Sav
Dorothy 66.555.00
Barbara 78,895. 50
Diane 50,000.00
Patricia 42.000.00
Lynette 22,000.10
Lenora 22,000.12
Sandy 32,000.00
Connie 12.000.00
Tatanisha 10,000.00
Diamond 690.00
Declare Names (10) as integer
Declare Savings, Total as Float
Declare K as integer
Set Sum = 0
For (K = 0; K<10; K++)
Write “Enter savings for Dorothy” + (K+1)
Input Savings
Step 2: With the help of for loop enter the values in both the arrays at same and corresponding index numbers
Declare Names (10)

• pseudocode - ,

Good start!
you may want to organize the pseudocode according to your teacher's specifications. Here are some hints.

Declaration
The instructions for part (a) requires 2 arrays, one for the family members and the other for savings.
They are parallel meaning that:
if names(4) contains Dorothy,
then savings(4) contains Dorothy's savings.
Initialization
These two arrays must be declared (but empty) in the main program. Some how they must be initialized, i.e. values put into them. This can be done by repeated interactive input as you suggested (Enter name:... Enter savings...), or by initialization of the array as stored input. You can clarify through your class notes or your teacher to see if there is a preference.

Method (b) total savings
You will need a function that returns the total from the given array.
Typically the function will be given the two arrays, AND the size of the array (10 in this case) so it will calculate the total savings and return the total as a value. You have a good skeleton of doing this: declaring total as a float, initialize it to zero, and then add the n(=10) savings to total using a for loop. Finally return the total as a value.

(c) function for maximum.
It is similar to (b), except that the total will be replaced by another variable called maxSavings. For each family member's saving, you would compare with maxSavings. If the family member's saving is greater, then maxSavings will be replaced by the current savings. By the end of the for-loop, maxSavings will contain the maximum. This value will be returned to the calling (main) function.

If you need clarifications, please post.
Feel free to post your revised pseudocode for comments.

### Answer This Question

 First Name: School Subject: Answer:

### Related Questions

More Related Questions

Post a New Question