C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Videos

Textbook Question
Book Icon
Chapter 4.5, Problem 3E

(Data processing) a. Write a program to display the following two prompts:

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.

Blurred answer
Students have asked these similar questions
(c) Write a program that asks the users to calculate volume of a rectangular prism, in cm², where the user needs to key in the value of length, width and height. The formula for the volume of a rectangular prism is given by: volume = length x width x height If the calculated volume is more than 100 cm², display a message indicating that the size of this rectangular prism is too big. If the calculated volume is less than 20 cm², display a message indicating that the size of this rectangular prism is too small. However, if the volume is in between 20 cm³ and 100 cm², display a message indicating that the size of this rectangular prism is moderate.
(Racing car) Write a program that simulates car racing, as shown in Figure 9.29b– d. The car moves from left to right. When it reaches the right end, it restarts from the left and continues the same process. Let the user increase and decrease the car’s speed by pressing the Up and Down arrow keys.Figure 9.29(a) The programs display a fan and (b–c) a moving car. (d) You can redraw a car with a new base point. Use Python
Question 1 (5% - 3 minutes) Assume that a Person is defined as shown here and that two variables are defined as follows: Person a, b; typedef struct p { char *name; unsigned char age: height: *friend; double struct p }Person; Complete the whole test based on this Person struct and variables a and b.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License