Java Reference
In-Depth Information
4. Write a program that prompts for two people's birthdays (month and day), along with today's month and day. The
program should figure out how many days remain until each user's birthday and which birthday is sooner. Hint: It is
much easier to solve this problem if you convert each date into an “absolute day” of year, from 1 through 365.
5. Write a program that computes a student's grade in a course. The course grade has three components: homework
assignments, a midterm exam, and a final exam. The program should prompt the user for all information necessary
to compute the grade, such as the number of homework assignments, the points earned and points possible for each
assignment, the midterm and final exam scores, and whether each exam was curved (and, if so, by how much).
Consider writing a variation of this program that reports what final exam score the student needs to get a certain
course grade.
6. A useful technique for catching typing errors is to use a check digit. For example, suppose that a school assigns a
six-digit number to each student. A seventh digit can be determined from the other digits with the use of the follow-
ing formula:
7th digit = (1 * (1st digit) + 2 * (2nd digit) + . . . + 6 * (6th digit)) % 10
When a user types in a student number, the user types all seven digits. If the number is typed incorrectly, the check
digit will fail to match in 90% of the cases. Write an interactive program that prompts for a six-digit student number
and reports the check digit for that number, using the preceding formula.
7. Write a program that displays Pascal's triangle:
1
11
121
1331
14641
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1
1 10 45 120 210 252 210 120 45 10
1
Use System.out.printf to format the output into fields of width 4.
 
Search WWH ::




Custom Search