|
Script to compute "Next anniversary"
Writing a program that takes in user input, and tells how many years remain until the next anniversary. We were told to compute it after March 2, 2011.
Here's what I have thus far:
import javax.swing.JOptionPane;
public class QuestionOne {
public static void main(String [] args) {
String marriageYear = JOptionPane.showInputDialog(null,
"What year did you get married in?","Year",JOptionPane.QUESTION_MESSAGE);
int intYear = Integer.parseInt(marriageYear);
String marriageMonth = JOptionPane.showInputDialog(null,
"What month?","Month",JOptionPane.QUESTION_MESSAGE);
int intMonth = Integer.parseInt(marriageMonth);
String marriageDay = JOptionPane.showInputDialog(null,
"What day?","Day",JOptionPane.QUESTION_MESSAGE);
int intDay = Integer.parseInt(marriageDay);
String output = "Wedding date: "+intMonth+"/"+intDay+"/"+intYear;
JOptionPane.showMessageDialog(null, output + "\nNext anniversary: ","Date"
,JOptionPane.PLAIN_MESSAGE);
}
}
I've read through the text and can't seem to think of a way to do the formula, any pointers?
|