surve in your ive been made available. Each contains data for one household. A single record includes an integer identification number, the annual income for the household, and the number of members of the household. You may assume that no more than 25 households were surveyed. Write a program to store the survey results into an array of user-defined structures of type household. The program should input the survey results from the user._The program should also perform the following operations: (Your program must provide a function for each of the following operations) • Calculate the average household income, and list the identification number and income of each household whose income exceeds the average. • Calculate the percentage of households having incomes below the poverty level. The poverty level, P, may be computed using the formula P = 2000 + 1000 • (m – 2) where m is the number of members in the household. Sample Input 24 5000 4 36 10000 5 45 2000 4 50 4000 2 55 6000 4

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
surve
in your
ive been made available. Each
contains data for one household. A single record includes an integer identification number,
the annual income for the household, and the number of members of the household. You
may assume that no more than 25 households were surveyed. Write a program to store the
survey results into an array of user-defined structures of type household.
The program should input the survey results from the user._The program should also
perform the following operations: (Your program must provide a function for each of the
following operations)
• Calculate the average household income, and list the identification number and
income of each household whose income exceeds the average.
• Calculate the percentage of households having incomes below the poverty level. The
poverty level, P, may be computed using the formula P = 2000 + 1000 • (m – 2)
where m is the number of members in the household.
Sample Input
24 5000 4
36 10000 5
45 2000 4
50 4000 2
55 6000 4
Transcribed Image Text:surve in your ive been made available. Each contains data for one household. A single record includes an integer identification number, the annual income for the household, and the number of members of the household. You may assume that no more than 25 households were surveyed. Write a program to store the survey results into an array of user-defined structures of type household. The program should input the survey results from the user._The program should also perform the following operations: (Your program must provide a function for each of the following operations) • Calculate the average household income, and list the identification number and income of each household whose income exceeds the average. • Calculate the percentage of households having incomes below the poverty level. The poverty level, P, may be computed using the formula P = 2000 + 1000 • (m – 2) where m is the number of members in the household. Sample Input 24 5000 4 36 10000 5 45 2000 4 50 4000 2 55 6000 4
Expert Solution
Step 1

Since you are not mentioning the programming language, here we are using C++ to complete the program.

PROGRAM:

//Header files

#include <iostream>

#include <iomanip>

#include<stdio.h>

 

//Using namespace

using namespace std;

 

//Defining average()

void average(int id[],int annual_income[],int household_number[],int count)

{

  int total=0;

  for(int i=0;i<count;i++)

  {

    //Finding the total income

    total=total+annual_income[i];

  }

  //Finding the average

  cout<<"\n"<<total/count<<endl;

  for(int i=0;i<count;i++)

  {

    if(annual_income[i]>total/count)

    {

      //Finding the highest average id and income

      cout<<id[i]<<" "<<annual_income[i]<<endl;

    }

  }

}

 

//Defining the percentage_hse() for poverty

void percentage_hse(int annual_income[],int household_number[],int count)

{

  int next=0;

  for(int i=0;i<count;i++)

  {

    //Computing poverty level

    int p=2000+1000*(household_number[i]-2);

 

    //Comparing with incomes

    if(annual_income[i]<p)

    next+=1;

  }

  //Computing the percentage

  float percentage=(float)next/(float)count;

 

  //Printing the percentage

  cout<<fixed << setprecision(2) <<percentage;

}

//Defining the main()

int main()

{

  //Declaring array to store the survey details

  int id[100],annual_income[100],household_number[100];

 

  //Declaring the variables

  int id_no,income,hse_no,count=0,total;

 

  //Getting total survey count

  cout<<"Enter number of surveys: ";

  cin>>total;

 

  //Getting survey details

  while(total!=0)

  {

    cin>>id_no>>income>>hse_no;

    id[count]=id_no;

    annual_income[count]=income;

    household_number[count]=hse_no;

    count++;

    total-=1;

  }

 

  //Calling the functions

  average(id,annual_income,household_number,count);

  percentage_hse(annual_income,household_number,count);

}

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY