It is intended that you complete this lab assignment during the lab session on Thursday, February 9. Be sure to finish the exercises from last week's lab with the same partner you had last week before starting this lab. You may choose to work on the exercises in this lab either on your own or with a programming partner. When you have finished, demonstrate your programs to the instructor or the lab assistant to receive credit for this lab.
If you do not finish during the Feb. 9 lab session, your work may be checked off at the start of the Feb. 16 lab session instead.
Complete each of the following programming exercises, either on your own or with a programming partner, at your discretion. When you or your team finishes a programming exercise, you (or both of you) will receive credit for that exercise.
Playing Cards: Do Programming Exercise P6.2 (page 226).
For those who may not be familiar with the playing cards for bridge, poker, rummy, etc., it may be helpful to point out that each playing card has both a value and a suit. There are ten numeric values, from 1 to 10 (except that the "1" card is called an "Ace", not a "1"), plus three face cards, so called because they have a picture of a "Jack", a "Queen", or a "King" on them. (No, I don't know what a "Jack" is -- it looks like some guy in a funny hat.) There are four sets of cards with these values in each deck of cards. Each set is called a "suit". Suits are named according to the shape of the icons the cards of that set: "Diamonds", "Hearts", "Spades", and "Clubs". (Clubs actually look like three-leafed clovers.) The following tables may be more useful than the table given in the textbook, because they show values separately from suits.
|
|
Note that you should write two Java classes:
Letter Grades: Do Programming Exercise P6.8 (page 227). Customize it to correspond to the alpha-four letter grade standard used at Augustana (and all Alberta universities) now. Our system is the same as that described in the textbook except that we have no grade of D-. If a user enters a non-existent grade, print the message "No such grade."
Leap Year: Do Programming Exercise P6.12 (page 228).
In the main method of your tester class, use the Scanner class to read the user's input from the keyboard, but ensure that the input typed by the user actually corresponds to a year (an integer) by calling the hasNextInt() method of the Scanner class prior to calling nextInt(), as shown on page 215. Your test class should pass the year number to the constructor of class Year, then call the isLeapYear() method of that class and print either "The year yyyy is not a leap year." or "The year yyyy is a leap year." (where "yyyy" is replaced by the year number entered by the user). If the user enters a year earlier than 1582, write "There were no leap years prior to 1582."
Test your program with at least the following year numbers:
| 2006 | no |
| 2004 | yes |
| 2000 | yes |
| 1900 | no |
| 1582 | no |
| 1580 | too early |
Each program in this set of lab exercises will be graded on a "mastery" basis — you will get full credit for the program if it works correctly, or no points if it is not completed. Each program will be worth 4 points, for a total of 12 points for this lab assignment.
Copyright © 2006 Jonathan Mohr