Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The date June 1 0 , 1 9 6 0 is special because when we write it in the following format, the month times the

The date June 10,1960 is special because when we write it in the following format, the month times the day equals the year:
6/10/60
Write a program that asks the user to enter a 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.
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.
Hints: do not use any string variables. The program will be much simpler if you read the three data items (ie., number inputs) into three separate int variables. This may require a deeper understanding of the extraction operator than has been needed up to this point in your programming experience. For example, 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. (HINT: Use an additional char variable to extract, store and display the / character )
Here is a sample run (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!
Assignment 1.2[20 points]
Write a C++ program that reads in three integer values that represent a month, date, and four-digit year. Your program should print the date in one of following formats depending on the user's input.
If the user enters 1, then print the month as a word ("January"), the date as an integer (11), and the year (1999).
If the user enters 2, then print the month as a three-letter abbreviation ( "Jan. "), date as an integer (11), and the year (1999).
If the user enters 3, then print month as an integer (01), the date as an integer (11), and the year (1999).
Here is a sample run (user's input shown in bold):
Please enter a date (three integers: month, day, year): 1211999
How would you like to print your date?
Month date, full year. (January 11,1999): Enter 1.
Abbreviated month date, full year (Jan.1,1999): Enter 2.
Month/date/year (12/1/1999): Enter 3.
1
If the user enters 1, then the output would be
December 1,1999.
Submit Your Work
Name your source code files according to the assignment number (a1_1.cpp, a1_2.cpp, etc.). Execute the program and copy/paste the output that is produced by your program into the bottom of the source code file, making it into a comment.

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago

Question

understand the key issues concerning international assignments

Answered: 1 week ago