Program that will allow a user to input list of their family

Assignment Help Programming Languages
Reference no: EM13806611

Problem Statement: Design a program that will allow a user to Input a list of their family members along with their age and state where they reside. Determine and output the average age of their family and output the names of anyone who lives in Texas. 

The program is to calculate the total average of the family age wise and determine their location with only printing out those members that are from Texas. The program will take inputs from the user who will input the name, age and location of each family member. The program will take the years of all members entered and add them all together and then take the total of members entered and divide the total coming up with the average age. The program will also calculate and identify each state of each person entered and using the defined input identifies those people from Texas and prints their names out only. The output of the program is three fold. The total average age of all family entries, identify who is from Texas and print their name out.

Required Output:

  • Average age of all persons entered
  • Printed name of person(s) from Texas ONLY

Required Input:

  • Name of person
  • Age of person
  • State of where person came from

The program will take inputs and calculate the average of all of the ages entered, identify which persons are from Texas and print their name.

An array will be used to hold the data for calculating who comes from Texas

First of all, user will be prompted to input number of family members. Then user will be asked to enter name, age and state of family members in a sentinel loop. In each iteration, user inputted values will be stored in respective arrays locations. Also the ages will be added.

Following formula will be used to calculate average age

AverageAge = SumAge / NumberOfMembers

Next loop will run as many times as number of family members. Inside this loop state array will be check to see if it has value 'Texas'. If so, the corresponding name array value will be printed.

Formula Used and Sample Input/Output:

The average age can be calculated by dividing the total age of all persons from the number of members. So, formula will be

AverageAge = SumAge / NumberOfMembers

Example input/output below:

*Entry in bold are user input

  • Enter number of family members: 3
  • Enter family member name: John
  • Enter family member age: 25
  • Enter family member state: NewYork
  • Enter family member name: Michael
  • Enter family member age: 55
  • Enter family member state: Texas
  • Enter family member name: Maria
  • Enter family member age: 50
  • Enter family member state: Texas

Average Age = 43.33

Members who lives in Texas

Michael lives in Texas

Maria lives in Texas

Array data:

  • Name [0] = John
  • Age[0] = 25
  • State[0] = "New York"
  • Name [1]=Michael
  • Age [1]=55
  • State [1]=Texas
  • Name [2]=Maria
  • Age [2]=50
  • State [2]=Texas

Calculating Average Age:

  • NumberOfMembers = 3
  • SumAge= Age[0] + Age [1] + Age [2] = 25 + 55 +50 = 130
  • AverageAge = SumAge/ NumberOfMembers = 130 / 3 = 43.3

Printing those who live in Texas

Loop from i=0 to NumberOfMembers-1

        If State[i] = "Texas"

                        Display Name[i], "lives in Texas"

        End if

                End For

  • State[1] is equal to Texas thus:
  • WRITE Name[1] "lives in Texas"
  • State[2] is equal to Texas thus:
  • WRITE Name[2] "lives in Texas"

Sr. No.

Variable Name

Default Value

Description

Data Type

Module Referenced

Scope

1.        

MAX_PERSONS

100

MAX_PERSONS is maximum array size (User can enter details of 100 members).

Integer

Main

Local

2.        

NumberOfMembers

0

integer to count number of family members

Integer

Input, Process, Output

Local

3.        

Name

100

array to store names of family members

String

Input, Output

Local

4.        

Age

100

array to store ages of family members

Integer

Input, Process, Output

Local

5.        

State

100

array to store states of family members

String

Input, Output

Local

6.        

AverageAge

0

store average age of family members

Integer

Process, Output

Local

7.        

SumAge

0

store addition of ages of family members

Integer

Process

Local

8.        

Index

0

Loop variable

Integer

Process, Output

Local

Reference no: EM13806611

Questions Cloud

What public policies influenced the court''s decision : Why did the court reach the holding that it did. What steps of logic did the court take in arriving at its decision
Implemented a distributed rental car management system : You implemented a distributed rental car management system using Java TCP Sockets and object streams. The goal of this project is to use code from your TCP project and create a new implementation of the rental car management system using Java RMI
Legislation relating to business regulation or taxation : A specific piece of legislation relating to business regulation or taxation. The "party platform" of either the Republican Party or the Democratic Party
Legislation relating to business regulation or taxation : A specific piece of legislation relating to business regulation or taxation. The "party platform" of either the Republican Party or the Democratic Party
Program that will allow a user to input list of their family : Problem Statement: Design a program that will allow a user to Input a list of their family members along with their age and state where they reside. Determine and output the average age of their family and output the names of anyone who lives in T..
U.s. government should continue to have the patriot act : Do you believe the U.S. Government should continue to have the Patriot Act in place given there still remain terrorist threats ex. (ISIS)
Examples on the use of kirchhoffs current law : Write an essay of 500 words, giving examples on the use of Kirchhoff's Current Law.
Original direction of motion of ball : Original direction of motion of ball - Solve these equations for the angle, θ′B, of ball B after the collision.
The patriot act was used to guarantee the ignorance : "The Patriot Act was used to guarantee the ignorance of the American people, so you will be deprived of real factual information that you could use to make an educated choice about what you want from leadership and foreign policy." Is Ms. Lindauer..

Reviews

Write a Review

Programming Languages Questions & Answers

  Ways to ensure that website is easy to navigate

A good practice would be to spread the content out among several pages. What are some ways to ensure that your website is easy to navigate?

  Write program that asks user for initial

Write a program that asks a user for his/her first initial. Then ask the user to type 1,2 3, 4. When the user types 4 the program ends. When the user types in 1, 2, or 3 , the program displays the message.

  How long will it take the program to run

How long will it take the program to run with 1000 processors, if each processor is as fast as the single processor on which the serial program was run?

  Iimplement a class called monetarycoin

Create an implement a class called MonetaryCoin that is derived from the class Coin class. Store a value in the in the monetary coin that represents its value.

  Enter codes of one to eight characters along

Consider a program to enter codes of one to eight characters along with an associated telephone number and associated notes. A code can represent a person's name, a person's initials, a place, or anything.

  Tic-tac-toe game

You have gathered your information on the AI for the Tic-Tac-Toe game and began to develop your own ways to improve it using C++. Now, it's time to present your findings in a final paper. Remember that your final analysis and recommendations m..

  Write the code for the instantiable class bus

Write the code for the instantiable class Bus, which represents a bus that moves passengers around in a simulated city. Bus objects have a ticket price, a maximum capacity of passengers, and a current number of passengers.

  Program display error message if test score is invalid

The program must display suiatble letter grade. The program must display an error message if the test score is 100.

  Required to implement parties - pair programming

Required to implement Parties - The player should be in his/her own Party and there can be other Parties (both hostile and non-hostile) as well. You should implement the user stories

  Implement to do a matrix-matrix product

Implement and check the time to do a matrix-matrix product of a 1000x500 matrix with a 500x800 matrix of floats sequentially and using 1,2,3,4, and 8 threads on dual and quad core processors.

  Create program to compute monthly interest

Create program to compute the monthly interest and print new balances for each of the savers. Then set annualInterestRate to 5% and compute the next month's interest

  This laboratory gives practice in the creation and use of

this laboratory provides practice in the creation and use of basic and advanced sql queries involving more than one

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd