MagicDates.java - import [email protected] Lemuel M [email protected] June 5 2013 Book Title From Control Structures through Objects by Tony

# MagicDates.java - import [email protected]

• Lab Report
• 1

This preview shows page 1 out of 1 page.

import javax.swing.JOptionPane; /** * @author Lemuel M. Uhuru * @Date June 5, 2013 * Book Title: From Control Structures through Objects by Tony Gaddis * Page: 189 Problem 2: Magic Dates * <p> * 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. */ public class MagicDates { public static void main(String[] args) { // Declare 3 variables to hold user input for month, day, and year. String input1, input2, input3; // Prompt user for input

#### You've reached the end of your free preview.

Want to read the whole page?

Unformatted text preview: input1 = JOptionPane.showInputDialog(null, "Enter a month in numeric form"); input2 = JOptionPane.showInputDialog(null, "Enter a day in numeric form"); input3 = JOptionPane.showInputDialog(null, "Enter a 2 digit year"); // Convert user input from String to Integer // and store in variables m, d, and y. int m = Integer.parseInt(input1); int d = Integer.parseInt(input2); int y = Integer.parseInt(input3); // Design decision structure to validate whether or not // the product of the month and day equals the year. if (m * d == y) { JOptionPane.showMessageDialog(null, "The date is magic!"); } else { JOptionPane.showMessageDialog(null, "The date is not magic!"); } } }...
View Full Document

• Spring '08
• Garcia,D
• Java Programming, Java Code, Equals sign, Lemuel M. Uhuru

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern