Java Magic Date Assignment Algorithm : JavaScript Magic Date Assignment Ask the
ID: 3568868 • Letter: J
Question
Java Magic Date Assignment
Algorithm: JavaScript Magic Date Assignment
Ask the user to enter a month (in numeric form), a day and a two-digit year.
Calculate the month times the day.
If the month times the day equals to the year, then display the date is magic. Otherwise, display the date is not magic.
I need find what is my mistake in my JavaScript code (doesn't work).
// Magic Date
public MagicDate(int month, int day, int year)
{
this.month = month;
this.day = day;
this.year = year;
// You might consider initializing `value` here as well, but I
// have no idea what it's for, so I can't give an example.
}
public void isMagic()
{
if (this.month * this.day == this.year)
System.out.println("Magic");
else
System.out.println("Not Magic");
}
Explanation / Answer
use Below code so that you can get result according to your requirement
class MagicDate{
public static void main(){
int month;//an innteger say 6
int day;//an integer say 2
int year;//two digit say 12
int dayofmonth=day*year;//multiple of month with year
if(dayofmonth==year){
System.out.println("This is magic date");//this will prints if month of days is equal to year
}
else
{
System.out.println("This is not magic date");//this will prints if month of days is not equal to year
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.