Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 6 (12 MARKS] Book Online is a business that sells rare books via the Internet and has the order delivered. Below is some of

image text in transcribedimage text in transcribed

Question 6 (12 MARKS] Book Online is a business that sells rare books via the Internet and has the order delivered. Below is some of the code for a GUI. Answer the questions that follows. import java.awt.*) import java.applet.*;. import java.awt.event.; import java.text.DecimalFormat; public class OrderApplet extends Applet implements ItemListener 1/ Create components for applet Label comanpyNameLabel - new Label ("Your online Bookstore"); Label priceLabel = new Label("Please enter the total amount of your order:"); TextField priceField - new TextField(35); Label deliveryLabel - new Label (Please choose your method of delivery:"); CheckboxGroup delivery Group - new CheckboxGroup(); Checkbox oneDayBox - new Checkbox "Priority Overnight), false, deliveryGroup); Checkbox twoDayBox - new Checkbox ("Express (2 business days)", false, deliveryGroup); Checkbox moreDaysBox - new Checkbox ("Standard (3 to 7 business days)", talse, deliveryGroup); Checkbox hiddenBox - new Checkbox ("", true, deliveryGroup); Label outputLabel - new Label("We guarantee on time delivery, or money back."); public void init() 11 Add components to window and set colors setBackground (Color. cyan); add (companyNameLabel); add (priceLabel); add (priceField); priceField. request Focus(); add (delivery Label); add (oneDayBox); oneDayBox. addItemListener(this); add (two DayBox); twoDayBox.addItemListener(this). add (noreDaysBox); moreDaysBox.addItemListener(this); add (outputLabel); (TURN OVER] public void itemStateChanged (ItemEvent choice) try double dellvery: double price; obtain the value of price and calculate the delivery fee- // Display output outputLabel.setForeground (Color.black); DecimalFormat twoDigitg - new Decimal Format ("R#, ###.00"); outputLabel.setText("Your total cost is " + twoDigits. format (price + delivery)); catch (Number FormatException e) outputLabel.setText ("Amount must be greater than 0"). outputLabel.setForeground (Color.red); hiddenBox.setState (true); priceField.setText(""); priceField. request Focus(); 6.3 6.1 What is the purpose of the statement in 1? 6.2 Draw the GUI that the statements in method creates. (6) Complete the method itemStateChanged in O. First obtain the value of the total amount of the order as well as the delivery method selected. Then calculate the final amount due as follows: (5) If the delivery method is priority, then the final amount is the order amount + 20%. If the delivery method is express, then the final amount is the order amount + 10%. If the delivery method is standard, and the order amount is greater than R75.00, then the final amount is the order amount, else add 5% to the final amount

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions