AP Java Ch. 3 Lab

Name:

Please write the code for each of the following.

1) Write the code that will determine if a user’s age makes them a minor.

2) Write a program that will take in the number of hours worked and figure out the weekly pay at or below 40 hours, but if it is more than 40 hours will figure out the over time pay. Include the following:

rate ($) = 15.00

standard (hours) = 40

pay (regular) = hours * rate

pay (overtime) = standard * rate + (hours-standard) * (rate*1.5)

3) Write the code that will take in three integers and determine which is the smallest integer.

4) Design and implement an application that reads an integer value representing a year input by the user. The program will determine if the year entered is a leap year. A year is a leap year if it is divisible by 4, unless it is divisible by 100 and not divisible by 400. For example 1900 is not a leap year but 2000 is. This is part of the Gregorian calendar therefore produce an error if a year is entered after the adoption of the calendar, 1582.

5) Design and implement an application that produces a multiplication table, showing the result of multiplying the integers from 1 though 12 by themselves.

(If you are finished with the WHOLE lab early, make a new code that allows the user to input the ending integer.) Listing 3.12 might be useful.

6) Design and implement an application that plays the Hi-Lo guessing game with numbers. The program should pick a random number between 1 and 100 (inclusively), then keep asking the user to guess the number. On each guess, report to the user whether or not they are correct or if the guess is too high or too low. Keep accepting guesses until the user is correct or quits. Count the number of guesses and report the value to the user when the user guesses correctly. At the end of each game (either by quitting or guessing correctly) ask the user if they want to play again. Keep playing games until the user chooses to stop. Listing 3.3 might be helpful.

7) Create a new version of the PalindromeTester program (Listing 3.9) so that spaces, punctuation, and changes in the uppercase and lowercase are ignored when determining whether a string is a palindrome. I would suggest enter the code and using a little before deciding how to go about this.