Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    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.

  • #3
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    216
    Thanks
    0
    Thanked 29 Times in 27 Posts
    Generally (and whatever language) there is less than a year before the next anniversary!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •