Write a program that asks the user to enter any date in the format specified above (month/day/2-digit-year). (It is very important that the input is in the correct format, typed all at once, all on one line, by the user. See the hints below.) The program should then determine whether the month times the day is equal to the year. If so, it should display a message saying the date is magic. Otherwise it should display a message saying the date is not magic.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter4: Control Structures I (selection)
Section: Chapter Questions
Problem 20PE: The cost of renting a room at a hotel is, say $100.00 per night. For special occasions, such as a...
icon
Related questions
icon
Concept explainers
Question

Write a program that asks the user to enter any date in the format specified above (month/day/2-digit-year). (It is very important that the input is in the correct format, typed all at once, all on one line, by the user. See the hints below.) The program should then determine whether the month times the day is equal to the year. If so, it should display a message saying the date is magic. Otherwise it should display a message saying the date is not magic.

Do not use any string variables in this assignment.

Hints: Read the three data into three separate int variables. Even though the user will be typing only one line of input, you will be using the extraction operator multiple times to read that input. I strongly suggest that you review lesson 2.9 before starting on this assignment.

To make your job easier, we will specify that it is still a valid date if the user uses a different punctuation character instead of a slash. For example, 6%10;60 would be a valid date (and a magic date).

Here are two sample runs (user's input shown in bold):

Enter a date in the format month/day/2-digit-year: 6/10/60 That is a magic date! Enter a date in the format month/day/2-digit-year: 6/10/61 That is not a magic date! C++

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Control Structure
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT