Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Day countdown in java

Name: Anonymous 2013-09-19 1:53

Sorry for asking, but here goes:

I'm a newfag to java have a programming assignment:

>Write a program that prints the number of days until the exam on 5/5/2014.

Halp mi, I have no idea how to even start.

Name: Anonymous 2013-09-19 1:56

This is what I have so far:

as you can tell, i am a total newb



public class DaysUntilTest
{  
    public static void main(String args[])
    {
        Day dayTesting = new Day(2014, 5, 5);
        Day dayNow = new Day(2014, 9, 18);
        int daysRemaining = dayTesting.daysFrom(dayNow);
       
        System.out.print("Today is: ");
        System.out.println(dayNow.toString());
       
        System.out.print("Day of the test: ");
        System.out.println(dayTesting.toString());
       
        System.out.print("Days remaining until the test: ");
        System.out.println(daysRemaining.toString());
       
    }
}

Name: Anonymous 2013-09-19 3:10

Here is the solution in J:

365*2014 05 05 tsdiff 3{.6!:0}.1

You're welcome!

Name: Anonymous 2013-09-19 18:35

le pedophile sage

Name: Anonymous 2013-09-20 1:46

>java

Name: Anonymous 2013-09-20 2:19

You need to get the difference (in days) between the day of the test and today.

For example, today is about 100000050 days since Jesus was born.
The test will be about 100000090 days after Jesus was born.
100000090 - 100000050 = 40 days

However, in CS we typically count the days since January 1st 1970.

I reccommend you look at the documentation for Java's Date object:
http://docs.oracle.com/javase/6/docs/api/java/util/Date.html
Figure out how to make a Date object for today and the date of the test, similar to how you have attempted here. Then find the diffference in time as I have suggested here.
You may need to convert from millliseconds to days, too. Not hard.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List