Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write the program that will get the user's age and print the word working years if age is between 16 and 65 and relax and

write the program that will get the user's age and print the word "working years" if age is between 16 and 65 and "relax and enjoy" if the age is odd and more than 66.

image text in transcribed

+ Tools Add-ons Help All changes saved in Drive mal text - Arial - 11 - BIUA G E- TE-E- 1 . . 2 . 3 . . . 4 . . . . 5 . 6 . The following set of programming problems will be covered in the single hour lecture of the course. HW-2 (Submit the .cpp file) Write a program that will get the user's age and print the words "Working Years" if age is between 16 and 65 and "Relax and Enjoy" if the age is odd and more than 66. Procedure: Start with the usual standard C++ block of statements (Just as in HW 1) Step 1: This program will need user input for the person's age, so you need to declare a variable for that. Since the person's age is a whole number we could use: int age; Step 2: Now collect the input from the user. It's best to display a message associated with each user input. Note: The variable after cin must be typed exactly as it was declared above. cout > age; Step 3: Immediately after the input is collected in the variable age we need to see if it is a valid age, meaning it must be a positive number, otherwise we want tell the user to input a valid number then exit the program. if ( (age = 16) and (age 66) and (age % 2 == 1) ) // age % 2 returns 0 or 1 cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Identify how culture affects appropriate leadership behavior

Answered: 1 week ago