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 7 of 7

Thread: Month Loop

  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Month Loop

    hey, i have been workin on a easter sunday app. ive done most of it but am stuck at a part.

    if the date of easter sunday is over 31, i need the output 2 read april and the date. e.g. i get march 38th wen i need april 7.init!!

    plss help me! its all im stuck on and have tried loadsa loops like while and for but i get problems wen i use "else". thnks, below is my work so far..


    public static void main(java.lang.String[] args)
    {
    int year;

    System.out.println("Please Enter a year between 1982 to 2048");

    year=EasyIn.getInt();

    while(year<1982||year>2048)
    {

    System.out.println("Please Re-enter");
    year=EasyIn.getInt();
    }

    int a=(year%19);
    int b=(year%4);
    int c=(year%7);
    int d=((19*a+24)%30);
    int e=((2*b+4*c+6*d+5)%7);
    int East=(22+d+e);
    char month;
    char March;
    char April;

    TROUBLE STARTS HERE!!!

    month=EasyIn.getChar();
    March=EasyIn.getChar();
    April=EasyIn.getChar();


    if(East>31);
    month=April;
    East=East-31;
    month=March;
    {
    System.out.println("Easter Sunday is"+month+""+East);

    }

    }

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You're in the wrong forum. This is JavaScript forum not Java. Ask the mod to move this thread to Computer Programming forum.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i though u guys are clever. u cnt work out wot i need 2 do??
    cmon!!!

  • #4
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if(East<=31)
    {
    System.out.println("Easter Sunday is March" +East);
    }
    else;
    {
    System.out.println("Easter Sunday is April" +East-31);
    }

    the red bit is highlighted and says "The operator named - is not defined for the argument type(s) java.lang.String, int"

    wots this?!? its the only thing holding me back from finishing this app!

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i wuld think u r clever enof to take the hint and realize u r posting in the wrong forum... Besides, there is no reason to be cross-posting ur questions.... Particularly in the wrong forum...

    .....Willy

  • #6
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by java_jenius
    i though[t] u guys are clever. u cnt work out wot i need 2 do??
    cmon!!!
    trolling .... ???
    *keep it simple (TM)

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    System.out.println("Easter Sunday is April" +East-31);

    Two words: Operator Precedence.

    A "jenius" ought to be able to figure it out based on those words but just to be sure you understand, the "+" operator takes precedence over the "-" operator so the "addition" is done first resulting in a string and then when the subtraction is attempted the string you're trying to subtract a value from definitely doesn't contain only numeric characters so it's an invalid operation.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

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