Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Gregorian to Julian and vise versa

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Gregorian to Julian and vise versa

    Hello i need help is it possible to make a program where you choose gregorian and the output is julian and vise versa in about 4 lines?
    please i need help i dont know how to start it

    I have this but its wrong and i dont know exactly what the output is because it has a problem.

    package calendar;
    public static void main(String[] args) {
    public class Calendar
    private static double julianDate(int year, int month, int day) { 
    if (month <= 2) { 
    year -= 1; 
    month += 12; } 
    double A = Math.floor(year / 100.0); 
    double B = 2 - A + Math.floor(A / 4.0); 
    double JD = Math.floor(365.25 * (year + 4716)) + Math.floor(30.6001 * (month + 1)) + day + B - 1524.5; 
    return JD;
        }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,149
    Thanks
    48
    Thanked 2,158 Times in 2,131 Posts

    Default Re: Gregorian to Julian and vise versa

    its wrong ...
    it has a problem.
    Please copy the full text of the error messages and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Gregorian to Julian and vise versa

    run:
    Error: Main method not found in class calendar.Calendar, please define the main method as:
    public static void main(String[] args)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 1 second)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,149
    Thanks
    48
    Thanked 2,158 Times in 2,131 Posts

    Default Re: Gregorian to Julian and vise versa

    Quote Originally Posted by heythisgreg View Post
    Hello i need help is it possible to make a program where you choose gregorian and the output is julian and vise versa in about 4 lines?
    please i need help i dont know how to start it

    I have this but its wrong and i dont know exactly what the output is because it has a problem.

    package calendar;
    public static void main(String[] args) {
    public class Calendar
    private static double julianDate(int year, int month, int day) { 
    if (month <= 2) { 
    year -= 1; 
    month += 12; } 
    double A = Math.floor(year / 100.0); 
    double B = 2 - A + Math.floor(A / 4.0); 
    double JD = Math.floor(365.25 * (year + 4716)) + Math.floor(30.6001 * (month + 1)) + day + B - 1524.5; 
    return JD;
        }
    }
    Where is the java source code that compiled so you could try to execute the program?
    The code you posted should generate some compiler errors that would prevent the compiler from creating a class file that is needed to be able to execute the program.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: Gregorian to Julian and vise versa

    If the message doesn't make sense after looking (carefully) at your code, then I suggest you look (carefully) at every working example in your textbook, class notes, on-line tutorial or whatever material you are learning from.

    Don't they all look kind of like this?

     
    // May have a package statement
     
    // May have one or more import statements
     
    public class Whatever {
     
        // May have various kinds of variables and/or methods for the class
     
        public static void main(String [] args) {
     
            // Stuff here that will be executed
     
        } // End of main
     
        // May have various kinds of variables and/or methods for the class
     
    } // End of class definition

    Bottom line: The main() thingie is a method of a public class, and, therefore, is defined totally within the class.


    Cheers!

    Z

Similar Threads

  1. Gregorian Calendar - Problems
    By BobDole6395 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 9th, 2012, 02:24 PM
  2. Replies: 9
    Last Post: March 16th, 2011, 11:35 AM
  3. Hi, I'm Julian !
    By julianms in forum Member Introductions
    Replies: 1
    Last Post: February 9th, 2010, 07:13 AM