Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

? Quiz2- Requires Respondus LockDown Browser- Quiz me Taken: 0:31:27 Navdeep Kau

ID: 3904046 • Letter: #

Question

? Quiz2- Requires Respondus LockDown Browser- Quiz me Taken: 0:31:27 Navdeep Kaur Attempt 1 Design an application that allows the user to calculate the tip for a restaurant bill. Provided a text field for the bill amount and a text field where the user can enter the tip percentage. A Calculate button will calculate and display the tip amount, HST/GST amount and Total amount in each text box. A Clear button will set the screen back to its default state. You don't have to write code for design. Write code for calculate and clear button. Following is sample example of how interface calculate and display value. Amount before tax: 150 Enter Tip Rate(%): 15 Tip amount HST/GST( 1 3%). Total Amount CALCULATE CLEAR public void start Stage primaryStage) C Button btni-new Button CALCULATE Eutton btn2ene Button CLEAR Te.tPield titip "new Tf'tfieldi) TextField tttipamountone TextField) blattamountii.tble tttipamcunt,bdthible btale

Explanation / Answer

btn1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
double tipAmt=Integer.parseInt(txtamount.getText())*Double.parseDouble(txttip.getText())*0.01;
txttipamount.setText(tipAmt+"");
double hst=Integer.parseInt(txtamount.getText())*0.13;
txthst.setText(hst+"");
double total=Integer.parseInt(txtamount.getText())+tipAmt+hst;
txttotal.setText(total+"");


}
});
btn2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
txtamount.setText("");
txttip.setText("");
txttipamount.setText("");
txthst.setText("");
txttotal.setText("");


}
});

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote