Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

CMPSC 221 Pennsylvania State University Pizza Serving Calculator Program

CMPSC 221 Pennsylvania State University Pizza Serving Calculator Program

Question Description

I’m working on a java question and need guidance to help me understand better.

Pizza Servings Calculator GUI Assignment

Write a GUI to calculate the number of servings that a circular pizza of a certain diameter will make. The GUI will have the following appearance:

Pizza Servings Calculator Initial

It must include the following features:

  • The frame title must say ‘Pizza Servings Calculator’.
  • A grid layout will be used for the GUI.
  • The JLabel title of the GUI will say ‘Pizza Servings Calculator’ and be in red and will be placed in grid slot 1.
  • A JLabel of ‘Enter the size of the pizza in inches: ‘ will be placed in grid slot 2 followed by a JTextField where the pizza size will be entered and have a width of 4.
  • A JButton will be placed in grid slot 3 and will contain ‘Calculate Servings’.
  • A JLabel, initially blank, will be placed in grid slot 4.

To execute the GUI, enter a pizza size in the JTextField and click the Calculate Servings button. The Calculate Servings button handler will then execute and calculate the number of servings and display it as shown in the following image:

Pizza Servings Calculator Final

The number of servings will be calculate using the following formula:

servings = (size / 8)**2

and displayed to two decimal places. You can use the Double.parseDouble(textField.getText() ) to get the string value from the JTextField and parse it to a double. This formula assumes that an 8 inch pie makes 1 serving. Based on the area of an 8″ pie as one serving, the number of servings will vary with the ratio of the radius of the new pie to the 8″ pie squared. Therefore, a 16″ pie would give you a ratio of 16/8 or 2 squared which is 4 servings.

Line 2 of the GUI contains two GUI components but each cell of a grid can only contain one component. This is where JPanels come in for GUI design. A JPanel is a container that simply holds other components, so we can use a JPanel as the component for line 2. We can create a JPanel by using a statement like:
private JPanel line2 = new JPanel();
Then we can add components to it with statements like:
line2.add(variable that represents your JLabel for Enter the size of the pizza…);
Then we can add line2 to the grid layout in slot 2.

To set the layout of the frame to a 4 line grid layout, you would use a setLayout statement such as:
setLayout(new GridLayout(4,1));

Once the servings have been calculated, they are displayed in the JLabel in grid slot 4 as shown.

Set the size of your GUI to (350, 300). This should give it the appearance as shown above. Your class that represents the GUI should extend JFrame.

Do not use the NetBeans GUI generator for this project.




Rubrics

?Frame

a. Title set to ‘Pizza Servings Calculator’ (5)

b. Size set to (350, 300). (5)

?Title Label

a. Text set to ‘Pizza Servings Calculator’ (2)

b. Text color set to red. (5)

c. Positioned in grid slot 1 (5)

d. Title is centered. (5)

?Enter Pizza size Prompt Label

a. Text set to ‘Enter the size of the pizza in inches: ‘. (3)

b. Positioned in grid slot 2. (5)

?Pizza size TextField

a. 4 columns wide. (5)

b. Positioned in grid slot 2. (5)

?Convert Button

a. Text set to ‘Calculate Servings’. (5)

b. Has a handler that implements ActionListener (5)

c. Calculates the proper number of servings (10)

d. Handler gets added to JFrame as ActionListener. (5)

e. Positioned in grid slot 3. (5)

?Number of servings Label

a. Text initially set to blank. (5)

b. On conversion, displays the number of servings to 2 decimal places. (10)

c. Positioned in grid slot 4. (5)

?Grid line 2

a. Use a JPanel to create line 2. (5)

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Executive Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Executive Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Executive Papers is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Executive Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.