(Data processing) a. Write a
Enter a month (use a 1 for Jan, etc.):
Enter a day of the month:
Have your program accept and store a number in the variable month in response to the first prompt and accept and store a number in the variable day in response to the second prompt.
If the month entered is not between 1 and 12, print a message informing the user that an invalid month has been entered. If the day entered is not between 1 and 31, print a message informing the user that an invalid day has been entered.
b. What will your program do if the user enters a number with a decimal point for the month? How can you make sure your if statements check for an integer number?
c. In a non-leap year, February has 28 days; the months January, March, May, July, August, October, and December have 31 days; and all other months have 30 days. Using this information, modify the program written in Exercise 3a to display a message when an invalid day is entered for a user-entered month. For this program, ignore leap years.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
C++ for Engineers and Scientists
- (Practice) Run Program 7.10 to determine the average and standard deviation of the following list of 15 grades: 68, 72, 78, 69, 85, 98, 95, 75, 77, 82, 84, 91, 89, 65, and 74.arrow_forwardFill in the blanks to rewrite the following statement: c. If x___________, then ________.arrow_forwardMake a truth table for each of the following statementsarrow_forward
- (8).Continue Print (*,*) X.arrow_forward-Convert SES variable to a factor and assign the value labels “low”, ”middle” and “high” to the 3 levels of thevariable. Then -Define the variables complic, comorb, depressi, diabetes as factors. For all these factors, a zero means “no” and a 1 means “yes”. Assign these value labels through the function factor() and check the change using str()arrow_forwardProduce the following program.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning