Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

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

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91376590
  • Price:- $60

Guranteed 36 Hours Delivery, In Price:- $60

Have any Question?


Related Questions in Programming Language

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As