• Home
  • Blog
  • You cannot ask the user how many family members will be input. I need hints on the added to the solution.

You cannot ask the user how many family members will be input. I need hints on the added to the solution.

0 comments

 

 

Part 1

Final Project Plan

Your final project will be to analyze, design, and document a simple program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements as well as function and subprogram calls and uses arrays.  The specific problem you need to solve for the final project is:  

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 lives in Texas.

For this part of the deliverable, there are 2 components of your submission including:

  • Program Description- A detailed, clear description of the program you are building.
  • Analysis- Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input? Also, include your variable names and definitions. Be sure to describe the necessary formulas and sample calculations that might be needed. Talk about the functions you plan to use and how you will use arrays. Be sure to talk about the types of programming statements that will be used on why.

Additional details about the program you need to write:

  1. Family sizes vary, however you should design to be able to enter at least 50 Family members.
  2. Your program needs to determine how many family members were input.You cannot ask the user how many family members will be input
  3. Your test cases should have at least 5 family members.
  4. Be sure to separate some functionality into functions or submodules. Having all functionality in the main module is not a good design.
  5. Your analysis should consider how to indicate the family member entry is complete.
  6. Carefully consider the best data type for each of your variables. (e.g. when to use Float versus Integers versus Strings)

 

Submission requirements:

Your completed assignment should be saved as Word document and submitted to your LEO assignment area no later than the due date. Your document should be neat, well-written with minimal grammatical and spelling errors. Your name should be clearly listed on the first page along with the class/section, professor and due date. Your document should contain page numbers at the bottom of each page. Use single space line formatting.

 

part 2

Final Project

Your final project will be to analyze, design, and document a simple program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements as well as function and subprogram calls and uses arrays.  The specific problem you need to solve for the final project is: 

 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 lives in Texas.

There are 2 components of your submission including:

  • Pseudocode- Provide pseudocode of your overall design that fulfills the requirements of the project
  • Test plan – Prepare at least 3 sets of input data (Test data) along with their expected output for testing your program. Your test data can be presented in the form of a table as follows (note: feel free to adapt to your design)

All of these components should be placed in a word document for submission.

Additional details about the program you need to write:

  1. Family sizes vary, however you should design to be able to enter at least 50 Family members.
  2. Your program needs to determine how many family members were input.  You cannot have as an input the number of family members to be input
  3. Your test cases should have at least 5 family members.
  4. Be sure to separate some functionality into functions or submodules. Having all functionality in the main module is not a good design.
  5. Your design should consider how to indicate the family member entry is complete.
  6. Carefully consider the best data type for each of your variables. (e.g. when to use Float versus Integers versus Strings)

 Example application test data:

Test Case #

Input

Expected Output

1

Fred, Age: 82, State: MD
Mary, Age:75, State: OH
Joe, Age: 45, State: TX
Julie, Age: 47, State: TX
Beth, Age: 9, State: TX

*

Average Age: 51.6
Members who live in TX:
  Joe
  Julie
  Beth

2

Your input data

Your expected output

3

Your input data

Your expected output

Submission requirements:

Your completed assignment should be saved as Word document and submitted to your LEO assignment area no later than the due date. Your document should be neat, well-written with minimal grammatical and spelling errors.

 

******THIS IS JUST EXTRA HELP*******

Hints for Final Project

Variables

Need three arrays, a string array for the names, a string array for the states, and an integer array for the ages

Need to specify the size of the array, and that it is an array in the analysis

Need integer variable to hold the number of family members entered

Need float variable to sum the ages, and to hold the average age

Look below at the two ways to get the names of the Texans. Based on which you choose you need either

a string scalar (a scalar is a variable that is not an array) that will hold the names of all of the Texans

a string array to hold the names of the Texans, and an integer variable that will hold the number of Texans found. If you use this approach, needto specify the size of the array

an integer variable to control the for loops you will use, and to serve as the index of the arrays when calculating the average age and generating the variable with the names of the Texans

Formulas in the analysis

You will need 3 formulas

Loading the arrays, and counting the number of family members input

Use the age array and the number of family members to calculate the average age (see details below)

use the name and state arrays, and the number of family members to generate either a string variable with the names of all of the Texans, or an array of strings with the names of all of the Texans

Do not output the name of a Texan when found, place in a variable

Loading the arrays

Cannot ask the user how many family members will be loaded

Use a sentinel loop to input family members, with the sentinel value being based on the name. Typically, the sentinel value is a name of *

Need to count the number of family members input and return this value for use later

Do not sum the ages while inputting them. This will be different from HW3

The order of the inputs may be tricky. Before the loop, load the first name. Do not load the first state and age.

Enter the loop. In the loop, do the following in the order shown

Input the age and state

add to the count of family members

input the next name

The formula for loading the arrays uses the following variables

Name – string array names of family members. You need to specify array size

Age – integer array ages of family members. You need to specify array size

State – string array state in which family member resides. You need to specify array size

Fam_Size – integer number of family members input

Formula for loading arrays

Fam_Size = 0

Input Name[Fam_Size]

While Name[Fam_Size] != “*”

Input Age[Fam_Size]

Input State [Fam_Size]

Fam_Size = Fam_Size + 1

Input Name[Fam_Size]

End While

When you do the sample calculation, a table very nicely shows what is going on. If I have three parallel arrays, named name, age, and state, and in the sample calculation I say the sample data is

Jeff, 61, MD, Doris, 53, VA, John, 55, TX, Ros, 91, VA, Francis, 91, TX, *

my sample calculation would show how the values were put in the arrays (showing the table at the end of each loop iteration, and at the end I would have

IndexArray

Name

Age

State

0

Jeff

61

MD

1

Doris

53

VA

2

John

55

TX

3

Ros

91

VA

4

Francis

91

TX

5

*

   

Note how the rows are identified by the index, and the columns are headed by the array name

Calculating the average

Use a for loop with the age array and number of family members to calculate the sum, then divide the sum by the number of family members

Formula

Set sum = 0.0

For (i = 0; i < num_family; i + 1)

Set sum = sum + age [i]

End For

Set Average_Age = sum/ num_family

Design considerations

Good application for a function

parameters are the age array and num_family

sum and i should be local variables

Finding the list of Texans

Look through the state array looking for a match to either Texas or TX (or either). If a match is found, the element in the name array with the same index is the name of a Texan

Need to decide which was of two approaches to use

String scalar approach

a scalar is a non-array variable. With this approach, each time a Texan is found the name is concatenated to the string variable. Need to initially set this variable to an empty string, and add the newline character after the name each time a new Texan is found.

In this approach, some of the variables are

Texans – string scalar containing the names of Texans

Family_Size – integer contains the number of family members input

iinteger variable controlling for loop and index of arrays

Formula for string scalar approach

Set Texans = “ “

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}