Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-19-2013, 05:29 AM   PM User | #1
Foogasm
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Foogasm is an unknown quantity at this point
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?
Foogasm is offline   Reply With Quote
Old 02-19-2013, 07:19 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,098
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia! Ask a mod to move this thread to the right forum.



It is your responsibility to die() if necessary….. - PHP Manual
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 02-19-2013, 12:02 PM   PM User | #3
007julien
Regular Coder

 
Join Date: May 2012
Location: France
Posts: 121
Thanks: 0
Thanked 18 Times in 16 Posts
007julien is an unknown quantity at this point
Generally (and whatever language) there is less than a year before the next anniversary!
007julien is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:13 AM.


Advertisement
Log in to turn off these ads.