Problem

Your freelance work with MyJava Lo-Fat Burgers was a success (see Exercise 22 of Chap. 5...

Your freelance work with MyJava Lo-Fat Burgers was a success (see Exercise 22 of Chap. 5). The management loved your new drive-through ordering system because the customer had to order an item from each of the three menu categories. As part of a public relations campaign, however, management decided to allow a customer to skip a menu category. Modify the program to handle this option. Before you list items from each category, use a confirmation dialog to ask the customer whether he or she wants to order an item from that category.

Reference Exercise 22.

For the following exercises, use the incremental development methodology to implement the program. For each exercise, identify the program tasks, create a design document with class descriptions, and draw the program diagram. Map out the development steps at the start. Present any design alternatives and justify your selection. Be sure to perform adequate testing at the end of each development step.

Write an application program that teaches children how to read a clock. Use JOptionPane to enter the hour and minute. Accept only numbers between 0 and 12 for hour and between 0 and 59 for minute. Print out an appropriate error message for an invalid input value. Draw a clock that looks something like this:

To draw a clock hand, you use the drawLine method of the Graphics class. The endpoints of the line are determined as follows:

The value for constant K determines the length of the clock hand. Make the K larger for the minute hand than for the hour hand. The angle of the minute hand is computed as

and the angle of the hour hand is computed as

where Hour and Minute are input values. The values 6.0 and 30.0 designate the degrees for 1 min and 1 h (i.e., the minute hand moves 6 degrees in 1 min and the hour hand moves 30.0 degrees in 1 h). The factor converts a degree into the radian equivalent. You can draw the clock on the content pane of a frame window by getting the content pane’s Graphic object as described in the chapter. Here’s some sample code:

You can draw the clock on the content pane of a frame window by getting the content pane’s Graphic object as described in the chapter. Here’s some sample code:

import javax.swing.*;

import java.awt.*; //for Graphics

...

JFrame win;

Container contentPane;

Graphics g;

...

win = new JFrame();

win.setSize(300, 300);

win.setLocation(100,100);

win.setVisible(true);

...

contentPane = win.getContentPane();

g = contentPane.getGraphics();

g.drawOval(50,50,200,200);

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6