Answered step by step
Verified Expert Solution
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
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 price Label = new Label("Please enter the total amount of your order:"); TextField priceField - new TextField (35); Label delivery Label - new Label ("Please choose your method of delivery:"); CheckboxGroup deliveryGroup - new CheckboxGroup(); Checkbox oneDayBox - new Checkbox( "Priority Overnight)", false, deliveryGroup); Checkbox two DayBox - new Checkbox ("Express (2 business days)", false, deliveryGroup); Checkbox moreDaysBox - new Checkbox("Standard (3 to 7 business days)", false, deliveryGroup); Checkbox hiddenBox = new Checkbox("", true, deliveryGroup): Label outputLabel - new Label("We guarantee on time delivery, or money back."); public void init() // Add components to window and set colors setBackground (Color.cyan); add (companyNameLabel); add (priceLabel); add (priceField); priceField. request Focus(); add (deliveryLabel); add (oneDayBox); oneDayBox.addItemListener(this); add (twoDayBox); twoDayBox.addItemListener(this). add (moreDaysBox); moreDaysBox.addItemListener(this); add (outputLabel); (TURN OVER] ALUT OCTOBER NOVEMBER 2019 public void itemStateChanged (ItemEvent choice) try double delivery: double price; obtain the value of price and calculate the delivery fee_ 1/ Display output output Label.setForeground (Color.black) Decimal Format twoDigits - new DecimalFormat ("R#, #*#.00"); output Label.setText ("Your total cost 13" + 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.1 6.2 6.3 What is the purpose of the statement in 1? Draw the GUI that the statements in method creates. (6) Complete the method itemStateChanged in . 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. 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 price Label = new Label("Please enter the total amount of your order:"); TextField priceField - new TextField (35); Label delivery Label - new Label ("Please choose your method of delivery:"); CheckboxGroup deliveryGroup - new CheckboxGroup(); Checkbox oneDayBox - new Checkbox( "Priority Overnight)", false, deliveryGroup); Checkbox two DayBox - new Checkbox ("Express (2 business days)", false, deliveryGroup); Checkbox moreDaysBox - new Checkbox("Standard (3 to 7 business days)", false, deliveryGroup); Checkbox hiddenBox = new Checkbox("", true, deliveryGroup): Label outputLabel - new Label("We guarantee on time delivery, or money back."); public void init() // Add components to window and set colors setBackground (Color.cyan); add (companyNameLabel); add (priceLabel); add (priceField); priceField. request Focus(); add (deliveryLabel); add (oneDayBox); oneDayBox.addItemListener(this); add (twoDayBox); twoDayBox.addItemListener(this). add (moreDaysBox); moreDaysBox.addItemListener(this); add (outputLabel); (TURN OVER] ALUT OCTOBER NOVEMBER 2019 public void itemStateChanged (ItemEvent choice) try double delivery: double price; obtain the value of price and calculate the delivery fee_ 1/ Display output output Label.setForeground (Color.black) Decimal Format twoDigits - new DecimalFormat ("R#, #*#.00"); output Label.setText ("Your total cost 13" + 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.1 6.2 6.3 What is the purpose of the statement in 1? Draw the GUI that the statements in method creates. (6) Complete the method itemStateChanged in . 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started