2. Magic Dates 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 month (in numeric form), a day, and a two-digit year. 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.
Added by Kayla R.
Close
Step 1
First, we need to import the Scanner class from the java.util package. This can be done by adding the following line at the beginning of our code: import java.util.Scanner; Show more…
Show all steps
Your feedback will help us improve your experience
Shaik Dadasaheb and 52 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Magic Dates The date June 10, 1960, is special because when it is written in the following format, the month times the day equals the year: 6/10/60 Create an application that lets the user enter a month (in numeric form), a day, and a two-digit year. The program should then determine whether the month times the day equals 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.
Shelayah R.
Write a program that prompts the user to enter a month (1-12) and a year (e.g., 2012), and then displays a calendar for that month and year as illustrated below: Your program must use the following methods: void printMonthCalendar(int m, int y) - Displays a calendar like the one above for a specified month and year. void printMonthHeader(int m, int y) - Displays the header information (month, year, line separator, 3-character day names) for a calendar. void printMonthBody(int m, int y) - Displays the days in the calendar associated with the corresponding days of the week. String getMonthName(int m) - Returns the name of the month for a specified month number (e.g., returns March for m=3). int getStartDay(int m, int d, int y) - Returns the day of the week number (1=Monday,..., 7=Sunday) for the specified month, day, and year. int getNumDaysInMonth(int m, int y) - Returns the number of days in a specified month and year. Leap years are accounted for. boolean isLeapYear(int y) - Returns true if the specified year is a leap year, and returns false otherwise.
Supreeta N.
Create a program that will accept integer values for the month, day, and year and then output the long version of the specified date. For example, if month = 11, day = 5, and year = 2010, output the string "November 5, 2010". If there is any invalid input, display "Invalid date" and end the program.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
100,000+
Students learning Computer Science with Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD