Part 1: Write the pseudo-code solving the following problem (-- > 5 points or no
ID: 674183 • Letter: P
Question
Part 1: Write the pseudo-code solving the following problem (-- > 5 points or nothing) The pseudo-code is expected to be of professional quality (sequence of unambiguous steps in plain English allowing the development of solution using a programming language)
Part 2: Write a program that fills an array A1 (representing the family income) with 100 random doubles between 5 000 and 50 000. At the same time you fill an array A2 with 100 random numbers representing the number of members in the family (a random number between 1 and 10) (-- > 5 points)
A family is considered to be poor, if the income is under 12 000 and there is one person in the family OR the income is under 13 000 and there are 2 members or more in the family.
For each “low income household”, the program displays (one household per line) (-- > 5 points) - the income - the number of members in the family
and at the end the program displays - the count of “poor families” in this simulation (-- > 5 points) - the average income in the group of “poor families” (the calculation of this average includes only the “poor families”) (-- > 5 points)
Explanation / Answer
Q1. Write a program that fills an array A1 (representing the family income) with 100 random doubles between 5 000 and 50 000.
double High1=50000;
double Low1= 5000;
int High2=10;
int Low2= 1;
double A1[100];
double A2[10];
for(int i=0;i<100;i++)
{
double randNum = rand()%(High1-Low1 + 1) + Low1;
A1[i]=randNum;
}
for(int i=0;i<100;i++)
{
double randNum = rand()%(High2-Low2 + 1) + Low2;
A2[i]=randNum;
}
Q2. Write the pseudo-code
1. check income of family. If income is under 13,000, go to step 2.
2. check number of family members. if number of members is 2 or more, then family is a "Low Income HouseHold" and go to Step 4. If family member less than 2, go to
Step 3.
3. If income is under 12,000 and number of members is less than 2, then it a "Low income Househol" and go to Step 4, else EXIT.
4. For families, going from 1 to 100, display the Income(A1), and Number of Members(A2). The average income is given by dividing the income of a family, by number of
members in the family.
5. The count of poor famiilies will be the total number of "Low Income HouseHold" Families.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.