主题:JAVA的高手来帮忙下。。!!
目前我还正在学习JAVA,在国外留学。。。可是遇到个很麻烦的程序。。。教授给我们布置了一题算简单可也算难的题目。。。。。我想了大概有7天左右了。。。可是还是无法写出来。。。希望哪个高手。。。可以帮小弟一忙!!~ 在这里先谢过了!!~~
以下是题目,由于在国外,所以都是以英文来出题的。
Write a program, that asks the user for a month, a day and a year.
The program should output what day of the year that day is.
For example.
Input example 1
Month 1
Day 30,
Year 2010
Output
Day of Year 30
Input example 2
Month 12
Day 31
Year 2008
Day of Year 366
Input example 3
Month 12
Day 31
Year 2010
Day of year 365
Your program should have at least 4 methods:
Input to input the month, day and year-will be called 3 times, once for each
Output to print the day of year
Calculate to do the actual calculations
Leapyear to calculate if the year is a leap year
Extra credit: add error checking: for example if the input is input
Month 2
Day 31
Year 2000
This date should be rejected
demonstrate your program with an error
For example:
1st do the method to determine if a year is a leap year, get it working
Then write a method to do the input, get it working
Then a method for output
Finally a method to do the calculations
Do as much as you can.
A working program will receive a B or better, nicer output; comments…will increase the grade
Rules for leap year
1. Every year that is evenly divisible by four is a leap year;
2. of those years, if it can be evenly divided by 100, it is NOT a leap year, unless
3. the year is evenly divisible by 400. Then it is a leap year.
以下是题目,由于在国外,所以都是以英文来出题的。
Write a program, that asks the user for a month, a day and a year.
The program should output what day of the year that day is.
For example.
Input example 1
Month 1
Day 30,
Year 2010
Output
Day of Year 30
Input example 2
Month 12
Day 31
Year 2008
Day of Year 366
Input example 3
Month 12
Day 31
Year 2010
Day of year 365
Your program should have at least 4 methods:
Input to input the month, day and year-will be called 3 times, once for each
Output to print the day of year
Calculate to do the actual calculations
Leapyear to calculate if the year is a leap year
Extra credit: add error checking: for example if the input is input
Month 2
Day 31
Year 2000
This date should be rejected
demonstrate your program with an error
For example:
1st do the method to determine if a year is a leap year, get it working
Then write a method to do the input, get it working
Then a method for output
Finally a method to do the calculations
Do as much as you can.
A working program will receive a B or better, nicer output; comments…will increase the grade
Rules for leap year
1. Every year that is evenly divisible by four is a leap year;
2. of those years, if it can be evenly divided by 100, it is NOT a leap year, unless
3. the year is evenly divisible by 400. Then it is a leap year.