...

View Full Version : Month Loop



java_jenius
08-18-2004, 10:43 PM
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);

}

}

glenngv
08-19-2004, 03:40 AM
You're in the wrong forum. This is JavaScript forum not Java. Ask the mod to move this thread to Computer Programming forum.

java_jenius
08-21-2004, 03:59 PM
i though u guys are clever. u cnt work out wot i need 2 do??
cmon!!!

java_jenius
08-22-2004, 02:17 PM
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!

Willy Duitt
08-22-2004, 02:47 PM
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 (http://www.codingforums.com/showthread.php?p=228141#post228141) ur questions.... Particularly in the wrong forum... :rolleyes:

.....Willy

jbot
08-23-2004, 10:35 PM
i though[t] u guys are clever. u cnt work out wot i need 2 do??
cmon!!!

trolling .... ???

Roy Sinclair
08-23-2004, 10:37 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum