I have these two problems I need to do for a class and am having the hardest time figuring out where to start on them.

1. Write a program that prompts the user to enter a month and year. and displays the number of days in the month. For example, if the user entered month 2 and year 2000, the program should display that of February 2000 has 29 days. (it also talks about remembering about Leap Year.)

2. An ISBN consists of 10 digits d1d2d3d4d5d6d7d8d9d10. The last digit is a checksum, which is calculated from the other nine digits using the following formula:
(d1 X 1 + d2 X 2 + d3 X 3 + d4 X 4 + d5 X 5 + d6 X 6 + d7 X 7 + d8 X 8 + d9 X 9) % 11
If the checksum is 10, the last digit is denoted X according to the ISBN convention. Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros) Your program should red the input as an integer.

I started a bit of number one, but have no idea where to even begin with 2. Help!

February 16th, 2011, 08:31 PM

aisthesis

Re: Help on this.

once you parse month and year as ints, 1) should go easily. I assume that 2000, as you say but without looking it up, is a leap year and ignore the adjustment that they throw in once in a great that's a bit more complicated than february just having 29 days every 4 years--i.e., i'll just assume that feb has 29 days every 4 years:

There are also formulas out there for making interesting date calculations, but if you just need number of days in the month with no more complications than dealing with normal leap years, that should get you there.