I am stuck on one question that is keeping me from completing myassignment. The
ID: 3618059 • Letter: I
Question
I am stuck on one question that is keeping me from completing myassignment.The date june 10,1960 is special because when we write it in thefollowing format, the month times the day equals the year;6/10/60
Write a program that asks the user to enter a month (in numericform), a day, and a two digit year. The program should thendetermine whether the month times the day is equal to the year. Ifso, it should display a message saying the date is magic.Otherwise, it should display a message saying the date is notmagic.
Explanation / Answer
//Hi, here is an example solution. This has been tested on theNetbeans 6.8 IDE and console to ensure that it works. //If you have question don't hesitate to ask via PM. import java.util.*; //Main class declaration public class Main { public static void main(String[] args) { //Create a scannerobject to obtain user input Scanner in = newScanner(System.in); //Prompt and obtainappropriate input from the user System.out.println("Enter in a month: "); int month =in.nextInt(); System.out.println("Enter in a date: "); int date =in.nextInt(); System.out.println("Enter in a year: "); int year =in.nextInt(); //check if the date ismagic or not if (date * month ==year) System.out.println("This date is magic!"); else System.out.println("This date isnt magic."); } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.