By using this site, you agree to our Privacy Policy and our Terms of Use. Close

Forums - General Discussion - Can someone help me with my Java Homework?

Can someone help me with my Java homework?

Love the site BTW, gonna post here for quite a long time. :)

The task is:

Write an application that will accept an intreger from the user that represents a year. Use the MODULUS operator ( % ) to determine if the year is divisible by 4. Print an appropriate message and how many years to the next leap year.

Use a while loop to repeat until the user enters a year of 99.

Reject non-integer input.

I use Crimson Editor, This homework is driving me nuts, i am so confused >.<.



Around the Network

Welcome to the site :) I take it you've been lurking for a bit before joining; I was the same case. There should be a few people here that know something about Java. I'm no programmer but wish you luck on your HW. Have you tried googling around for some help?



If it was c++ sure but I don't play with java enough :P



Yeah, I have been lurking this site for ages, I even used it for a sales assignment for reference, and i got an A.

No I haven't googled around too much, I will certainly have a look at various sites though :D.



Yea sry bro but I never touched java and don't know what the code is like, in c++ i could do it in like a few mins :D but if anyone can tell me java is like c++ then i could totally help ya out

example of c++

int year = 0;
cout << "enter 99 to end program" << endl;
while(year != 99)
{
cout << message here << endl;
cin >> year;
leap = year % 4;
if (leap = 0)
{
cout << "Next leap year etc" << endl;
}
else if(leap != 0)
{
cout << Blah blah << endl;
}
}



Around the Network

Yeah thanks, I think they are very similar, but they do have there differences when used for different things,

Thanks heaps anyway :D



Oh yea forgot to add reject integer :P o well hopefully seeing that example you should be able to make it in java.