Question

Write an if/else statement that adds 1 to minors if age is less than 18, adds...

Write an if/else statement that adds 1 to minors if age is less than 18, adds 1 to adults if age is 18 through 64 and adds 1 to seniors if age is 65 or older.

Homework Answers

Answer #1

Note: This code is wrtieen using "C".

if(age<18)
        minors = minors+1;
    else if (age>=18 && age<=64)
        adults= adults+1;
    else
        seniors= seniors+1;

The IF condition checks for the age < 18 and if its true then it increments minors or else go to next branching

Now IF is false then it comes to else if and checks that age should be in the range between 18 and 64; The logical operator "&&" checks and returns TRUE if both conditions are met or else it executes the ELSE statement.

If above both are false, then ELSE will be executed for age greater than or equal 65 people.

Any queires comment.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Video games are played by both minors under the age of 18 and adults over the...
Video games are played by both minors under the age of 18 and adults over the age of 18. Let us focus on the adult video game players. Records indicate that 42% of them are within the age of 18 – 25, 23% are within the age of 26 – 35, 17% are within the age of 36 – 45 and the remaining are 46 and older. Records also indicate that 72% of the video game players aged within 18...
in C++ Write a program to use the IF ELSE statement in the following way. Have...
in C++ Write a program to use the IF ELSE statement in the following way. Have the user input a value, x If the value is less than 100, present, "you got 5% interest" and display on the screen the total of the X*1.05 Else print on the screen, "you got 10% interest", and display the value X*1.10.
1. For traditional college-age people (18-25), consuming moderate or high amounts of alcohol have what, if...
1. For traditional college-age people (18-25), consuming moderate or high amounts of alcohol have what, if any effect, on the parts of the brain that involve decision making? No effect Short-term problems (lasting 3-12 hours) Mid-term problems (lasting 2-3 days) Long-term problems (lasting 3-8 weeks) Permanent damage Not sure 2. Compared to older adults, traditional college-age drinkers are ____ likely to experience an alcohol blackout. More Unsure Less 3. Alcohol dependency is more likely in ____. A. Traditional college-age adults...
Write a program that checks the age of a user (C++ Programming)    If the user...
Write a program that checks the age of a user (C++ Programming)    If the user is 18 to 20 print “Sing a song” If the user is younger than 18 then print “Please show a dance step” Else Welcome the user and print “You are audience”
A certain financial services company uses surveys of adults age 18 and older to determine if...
A certain financial services company uses surveys of adults age 18 and older to determine if personal financial fitness is changing over time. A recent sample of 1,000 adults showed 410 indicating that their financial security was more than fair. Suppose that just a year before, a sample of 800 adults showed 280 indicating that their financial security was more than fair. What is the 95% confidence interval estimate of the difference between the two population proportions? (Round your answers...
Question 18: Height and age: Are older men shorter than younger men? According to a national...
Question 18: Height and age: Are older men shorter than younger men? According to a national report, the mean height for U.S. men is 69.4 inches. In a sample of 170 men between the ages of 60 and 69 , the mean height was =x69.3 inches. Public health officials want to determine whether the mean height μ for older men is less than the mean height of all adult men. Assume the population standard deviation to be =σ2.71 . Use...
A person is said to be overweight if his or her Body Mass Index is between...
A person is said to be overweight if his or her Body Mass Index is between 25 and 29, inclusive, and a person is said to be obese if his or her Body Mass Index is 30 or greater. In 2018, the Utah Department of Health issued the following table. The first two columns of the table provide the age distribution for adults living in Utah. The third column gives the percentage of adults in each age group who are...
Country Financial, a financial services company, uses surveys of adults age 18 and older to determine...
Country Financial, a financial services company, uses surveys of adults age 18 and older to determine if personal financial fitness is changing over time (USA Today, April 4, 2012). In February of 2012, a sample of 1000 adults showed 410 indicating that their financial security was more than fair. In February of 2010, a sample of  900 adults showed 315 indicating that their financial security was more than fair. What is a 99% confidence interval estimate of the difference between the...
An article about the California lottery gave the following information on the age distribution of adults...
An article about the California lottery gave the following information on the age distribution of adults in California: 35% are between 18 and 34 years old, 51% are between 35 and 64 years old, and 14% are 65 years old or older. The article also gave information on the age distribution of those who purchase lottery tickets. The following table is consistent with the values given in the article. Suppose that the data resulted from a random sample of 200...
Country Financial, a financial services company, uses surveys of adults age 18 and older to determine...
Country Financial, a financial services company, uses surveys of adults age 18 and older to determine if personal financial fitness is changing over time (USA Today, April 4, 2012). In February of 2012, a sample of 1000 adults showed 410 indicating that their financial security was more than fair. In February of 2010, a sample of  900 adults showed 315 indicating that their financial security was more than fair. What is a 99% confidence interval estimate of the difference between the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT