its a JavaFX project Create a working order form for Orinoco as shown. Sales tax is 7%. To display the Total Due (a Label) as currency, research how to use class NumberFormat.  package application;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

its a JavaFX project

Create a working order form for Orinoco as shown. Sales tax is 7%.
To display the Total Due (a Label) as currency, research how to use class NumberFormat

package application;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;


public class Main extends Application {
TextField itemField,quantityField,priceField;
Label totalValue;
CheckBox isTaxable;
ToggleGroup shipping;
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("orinoco.com");

GridPane rootNode = new GridPane();
rootNode.setPadding(new Insets(25));
rootNode.setHgap(10);
rootNode.setVgap(10);

Scene scene = new Scene(rootNode);
//create labels for order
rootNode.add(new Label("Item"),0,0);
itemField=new TextField();
rootNode.add(itemField,1,0);

rootNode.add(new Label("Price"),0,1);
priceField = new TextField();
rootNode.add(priceField,1,1);

rootNode.add(new Label("Quantity"),0,2);
quantityField = new TextField();
rootNode.add(quantityField,1,2);


isTaxable = new CheckBox("Taxable?");
rootNode.add(isTaxable,1,3);

rootNode.add(new Label("Shipping"),0,4);

//create toggle group
shipping=new ToggleGroup();

//create radiobuttons for shipping time
RadioButton r1 = new RadioButton("$20");
RadioButton r2 = new RadioButton("$12");
RadioButton r3 = new RadioButton("$5");

r1.setToggleGroup(shipping);
r2.setToggleGroup(shipping);
r3.setToggleGroup(shipping);

rootNode.add(new Label("Next Day"),0,5);
rootNode.add(r1,1,5);

rootNode.add(new Label("This Week"),0,6);
rootNode.add(r2,1,6);

rootNode.add(new Label("Some Day"),0,7);
rootNode.add(r3,1,7);

totalValue = new Label();

rootNode.add(new Label("Total Due"),0,8);
rootNode.add(totalValue,1,8);

Button processButton = new Button("Process");
rootNode.add(processButton,0,9);
processButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
calculateAndSetValues();
}
});
Button resetButton = new Button("Reset");
rootNode.add(resetButton,1,9);
resetButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
itemField.setText("");
quantityField.setText("");
priceField.setText("");
isTaxable.setSelected(false);
shipping.selectToggle(null);
totalValue.setText("");

}
});
primaryStage.setScene(scene);
primaryStage.show();
}
private void calculateAndSetValues() {
double quantity = Double.parseDouble(quantityField.getText());
double price = Double.parseDouble(priceField.getText());
double amount = quantity * price;

if(isTaxable.isSelected()) {
amount+=amount*0.07;
}
RadioButton rb = (RadioButton)shipping.getSelectedToggle();
amount+=Double.parseDouble(rb.getText().substring(1));

totalValue.setText("$"+String.format("%2f",amount));
}

public static void main(String[] args) {
launch(args);
}
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY