Try the fastest way to create flashcards

Related questions with answers

Question

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/606/10/60

Write a program that asks the user to enter a month (in numeric form), a day, and a twodigit 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

Solution

Verified
Answered 6 months ago
Answered 6 months ago
Step 1
1 of 3

The code:

import java.util.*;

public class MagicDates {
    public static void main(String[] argv){
        int mon, day, year;
        Scanner keyboard = new Scanner(System.in);
    
        System.out.print(Enter a month: );
        mon = keyboard.nextInt();
        System.out.print(Enter a day: );
        day = keyboard.nextInt();
        System.out.print(Enter a year (two-digit): );
        year = keyboard.nextInt();
        
        if (mon * day == year)
            System.out.println(The date is magic!);
        else
            System.out.println(The date is not magic.);
        
            keyboard.close();
    }
}

Create a free account to view solutions

Create a free account to view solutions

Recommended textbook solutions

Starting Out with Java: From Control Structures Through Objects 5th Edition by Tony Gaddis

Starting Out with Java: From Control Structures Through Objects

5th EditionISBN: 9780132855839 (1 more)Tony Gaddis
1,102 solutions
Fundamentals of Database Systems 7th Edition by Ramez Elmasri, Shamkant B. Navathe

Fundamentals of Database Systems

7th EditionISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe
948 solutions
Introduction to Algorithms 3rd Edition by Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

Introduction to Algorithms

3rd EditionISBN: 9780262033848Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
872 solutions
Introduction to Algorithms 4th Edition by Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

Introduction to Algorithms

4th EditionISBN: 9780262046305Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
945 solutions

More related questions

1/4

1/7