Starting from:

$20

Write an application that prompts a user for a month, day, and year

Chp 5

a. Write an application that prompts a user for a month, day, and year. Display a message that specifies whether the entered date is

1. not this year,

2. in an earlier month this year,

3. in a later month this year, or

4. this month.

Save the file as PastPresentFuture.java.

b. Use the Web to learn how to use the LocalDate Boolean methods isBefore(), isAfter(), and equals(). Use your knowledge to write a program that prompts a user for a month, day, and year, and then displays a message specifying whether the entered day is in the past, the current date, or in the future. Save the file as PastPresentFuture2.java.

7. Create a class that holds data about a job applicant. Include a name, a phone number, and four Boolean fields that represent whether the applicant is skilled in each of the following areas: word processing, spreadsheets, databases, and graphics. Include a constructor that accepts values for each of the fields. Also include a get method for each field. Create an application that instantiates several job applicant objects and pass each in turn to a Boolean method that determines whether each applicant is qualified for an interview. Then, in the main() method, display an appropriate method for each applicant. A qualified applicant has at least three of the four skills. Save the files as JobApplicant.java and TestJobApplicants.java.



Chp 6

2.

a. Write an application that counts by three from 3 through 300 inclusive, and that starts a new line after every multiple of 30 (30, 60, 90, and so on). Save the file as CountByThrees.java.

b. Modify the CountByThrees application so that the user enters the value to count by. Start each new line after 10 values have been displayed. Save the file as CountByAnything.java.

8.

Write an application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as TestScoreStatistics.java.

Chp 7

1. Write an application that prompts the user for three first names and concatenates them in every possible two-name combination so that new parents can easily compare them to find the most pleasing baby name. Save the file as BabyNameComparison.java.

2.

1. Create a program that contains a String that holds your favorite movie quote and display the total number of spaces contained in the String. Save the file as CountMovieSpaces.java.

2. Write an application that counts the total number of spaces contained in a movie quote entered by the user. Save the file as CountMovieSpaces2.java.

Chp 8

1. Write an application that stores 12 integers in an array. Display the integers from first to last, and then display the integers from last to first. Save the file as TwelveInts.java.

2. Allow a user to enter any number of double values up to 20. The user should enter 99999 to quit entering numbers. Display an error message if the user quits without entering any numbers; otherwise, display each entered value and its distance from the average. Save the file as DistanceFromAverage.java.

Chp 9

1. Radio station JAVA wants a class to keep track of recordings it plays. Create a class named Recording that contains fields to hold methods for setting and getting a Recording’s title, artist, and playing time in seconds. Save the file as Recording.java.

2. Write an application that instantiates five Recording objects and prompts the user for values for the data fields. Then prompt the user to enter which field the Recordings should be sorted by—song title, artist, or playing time. Perform the requested sort procedure, and display the Recording objects. Save the file as RecordingSort.java.

Chp 10

1. Create a class named Horse that contains data fields for the name, color, and birth year. Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field that holds the number of races in which the horse has competed and additional methods to get and set the new field. Write an application that demonstrates using objects of each class. Save the files as Horse.java, RaceHorse.java, and DemoHorses.java.

2. Mick’s Wicks makes candles in various sizes. Create a class for the business named Candle that contains data fields for color, height, and price. Create get methods for all three fields. Create set methods for color and height, but not for price. Instead, when height is set, determine the price as $2 per inch. Create a child class named ScentedCandle that contains an additional data field named scent and methods to get and set it. In the child class, override the parent’s setHeight() method to set the price of a ScentedCandle object at $3 per inch. Write an application that instantiates an object of each type and displays the details. Save the files as Candle.java, ScentedCandle.java, and DemoCandles.java.

Chp 12

1. Write an application named BadSubscriptCaught in which you declare an array of 10 first names. Write a try block in which you prompt the user for an integer and display the name in the requested position. Create a catch block that catches the potential ArrayIndexOutOfBoundsException thrown when the user enters a number that is out of range. The catch block should also display an error message. Save the file as BadSubscriptCaught.java.

2. The Double.parseDouble() method requires a String argument, but it fails if the String cannot be converted to a floating-point number. Write an application in which you try accepting a double input from a user and catch a NumberFormatException if one is thrown. The catch block forces the number to 0 and displays an appropriate error message. Following the catch block, display the number. Save the file as TryToParseDouble.java.

Chp 13

1. Create a file using any word-processing program or text editor. Write an application that displays the file’s name, containing folder, size, and time of last modification. Save the file as FileStatistics.java.

2. Create three files of any type you choose—for example, word-processing documents, spreadsheets, or pictures. Write an application that determines whether the first two files are located in the same folder as the third one. Test the program when the files are in the same folder and when they are not. Save the file as CompareFolders.java.





Chp 14

1. Write an application for Lambert’s Vacation Rentals. Use separate ButtonGroups to allow a client to select one of three locations, the number of bedrooms, and whether meals are included in the rental. Assume that the locations are parkside for $600 per week, poolside for $750 per week, or lakeside for $825 per week. Assume that the rentals have one, two, or three bedrooms and that each bedroom over one adds $75 to the base price. Assume that if meals are added, the price is $200 more per rental. Save the file as JVacationRental.java.

2.

1. Write an application that allows a user to select one of at least five television shows to watch on demand. When the user selects a show, display a brief synopsis. Save the file as JTVDownload.java.

2. Change the JTVDownload application to include an editable combo box. Allow the user to type the name of a television show and display an appropriate error message if the desired show is not available. Save the file as JTVDownload2.java.

Chp 15

1. Create a JFrame that holds five buttons with the names of five different fonts. Include a sixth button that the user can click to make a font larger or smaller. Display a demonstration JLabel using the font and size that the user selects. Save the file as JFontSelector.java.

2. Create a JFrame that uses BorderLayout. Place a JButton in the center region. Each time the user clicks the JButton, change the background color in one of the other regions. Save the file as JColorFrame.java.

Chp 16

1. Write an application that extends JPanel and displays a phrase in every font size from 6 through 20. Save the file as JFontSizesPanel.java.

2.

1. Write an application that extends JPanel and displays a phrase in a large font. Each time the user clicks a JButton, display the same phrase in a different color, a little further to the right, and in a slightly smaller font. Allow only three clicks. Save the file as JChangeSizeAndColorPanel.java.

2. Modify the JChangeSizeAndColorPanel application so that it continuously changes the size, color, and location of a phrase as long as the user continues to click the button. Save the application as JChangeSizeAndColorPanel2.java.

3. Write an application that extends JPanel and displays a phrase. Each time the user clicks a button, alternate between displaying the phrase upside down and right-side up. Save the application as JUpsideDownPanel.java.



SOLUTIONS FOR ALL THE WEEKS ARE INCLUDED AS ABONUS

More products