# Creative Writing

Topics: Ring, Chicago, Variable Pages: 5 (813 words) Published: February 28, 2013

Student Name:
Class/Section:
Professor Name:
Assignment due date:

1. Problem definition: Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who live in Texas. Note: Your problem analysis should have already been submitted as part 1 of the assignment. A. Program Design – Following the directions in the assignment, clearly write up your problem design in this section and comment your pseudocode. The following items are the things the program must do:

* Declare the age, name and state arrays for the family members * The enter values by the users will decide the arrays
* The loop will consist of the input of the state, name, age * It will calculate the average age of members and names who reside in Texas * Results of the average age and names of family members who live in Texas The user will enter 10 family members name, age, and place of residence (state) to be stored in the arrays listed below. With a one to one correspondence for arrays sState, sName, and iAge, family members name will be entered in sName array and will have their state and age entered in sState and iAge arrays respectively. Variables will be defined as:

* sState – string array to hold the state
* sName – string array to hold the name
* iAge – integer array to hold the age
* iCount – integer to hold the count

The Main module will contain the following submodules:
* CalcAvgAge
* PntTexans

Formula Examples
Calculating Average Age:
Average Age = (total of all family members ages)/(total number of family member)

Example:
iCount = 4 and iAge[0]=7 ; iAge[1]=52 ; iAge[2]=30 ; iAge[3]=16

CalcAvgAge = (iAge[0] + iAge[1] + iAge[2] + iAge[3])/ (iCount) 7+52+30+16/4 = 26
Average Age = 26
Print Texans:
In sState array, you will be looking for the string that contain the state name “Texas” and print the corresponding family member name in sName.

Example:

IF:
sState[1]=“Texas”; sState[2]=“Texas”; sState[3]=“Texas” sName[0]= “Kevin”; sName[1]= “Maliya”; sName[2]= “Nicole”; sName[3]= “Paul” Printed Results:
Maliya
Nicole
Paul

Pseudocodes
// Programmer: Genita Joyner
// Oct 12, 2012
// This program will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who live in Texas

Main Module// Start Program
Declare sState as String Array// Array to store state
Declare sName as String Array// Array to store name
Declare iAge as Integer Array// Array to store age
Declare iCount as Integer // Variable to hold count of total family members Delclare Avg_Age as Float// Variable to hold average family age Declare lc as Integer// Loop counter
While // Loop for family data input
Display “Enter Family Member Name”
Input sName (lc)// Input name
Display “Enter Family Member Age”
Input iAge (lc)// Input age
Display “Enter Family Member State”
Input sState (lc)// Input state
Increment iCount and lc
End While
Call CalcAvgAge (iAge, iCount)// Call module to calculate and display average age Call PntTexans (sState, sName, iCount)// Call module to print the name of Texans End Main// End Program
************************************************************************ CalcAvgAge Module// Start Program to calculate average age
Declare Avg_Age as Float// Variable to hold average family age
Declare lc1 as Integer // Loop counter
Declare Total as Integer// Variable to hold the total number of ages
While (lc1< iCount)// Loop to total all ages
Total = Toal + iAge
Increment lc1
End While
Avg_Age = Total/ iCount// Calculate average age
Print Avg_Age//...