Results 1 to 6 of 6
  1. #1
    jbmanz is offline Member
    Join Date
    Mar 2015
    Posts
    3
    Rep Power
    0

    Default math problem by date

    I want to be able to use the current date to solve a math problem, specifically as follows:
    If today is March 17, the math problem of the day should be:

    (Month times Day of Month) + 99 = Answer of the Day
    (3 x 17) + 99 = 150

    How can I create a java script to find the current month and the current day of month, multiple those two together, then add 99 and display the answer as a result.

    Thank you -
    - JB

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: math problem by date

    Did you have a look at the Calendar class API?

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: math problem by date

    Quote Originally Posted by jbmanz View Post
    How can I create a java script
    Are you talking about a Java program or javascript here?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    jbmanz is offline Member
    Join Date
    Mar 2015
    Posts
    3
    Rep Power
    0

    Default Re: math problem by date

    Not yet, not sure what that is. Is that another thread on this forum ? Do you have a link to share ?
    I have never taken any java training/classes, only played with some scripts provided by co-workers to tweak them, I'm very new/inexperienced with java and learning on the fly just for fun.

  5. #5
    jbmanz is offline Member
    Join Date
    Mar 2015
    Posts
    3
    Rep Power
    0

    Default Re: math problem by date

    Quote Originally Posted by gimbal2 View Post
    Are you talking about a Java program or javascript here?
    I'm thinking script - what I'd like to do is embed the script (or reference it using "script src=" ) in a simple HTML page so when the page loads
    the top of it can read something like: "The answer of the day is: X" ( x = answer to the math problem).
    Last edited by jbmanz; 03-17-2015 at 02:10 PM.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: math problem by date

    That's javascript. You're in the wrong forum. Java is not Javascript.

    Well whatever, you're here now and you asked the question; basic javascript date capabilities are quite limited. I have used an API called momentjs in the past which works quite well:

    http://momentjs.com/

    That's not the only one available. You'll just have to experiment and see what works for you.
    Last edited by gimbal2; 03-17-2015 at 02:18 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Date Math with weekends & holidays?
    By ShaneO in forum New To Java
    Replies: 3
    Last Post: 07-10-2013, 09:05 AM
  2. Can't get my date math to work
    By pahiker in forum New To Java
    Replies: 8
    Last Post: 07-13-2010, 02:06 AM
  3. Math Related Problem
    By perito in forum Advanced Java
    Replies: 1
    Last Post: 03-21-2008, 08:53 AM
  4. Math Related Problem
    By perito in forum New To Java
    Replies: 3
    Last Post: 03-20-2008, 05:22 PM
  5. Date math
    By orchid in forum New To Java
    Replies: 2
    Last Post: 04-18-2007, 07:01 AM

Tags for this Thread

Posting Permissions

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