Question

Lab Chapter 12 Vinnies Auto Shop performs the following routine maintenance services: • Oil change: $35.00 • Lube job: $25 •


• Documentation Requirements o Your last name and Lab title are contained in the demonstrating program name. Also, after Chap
0 0
Add a comment Improve this question Transcribed image text
Answer #1

VinnieAutoShopFXML.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>


<AnchorPane id="AnchorPane" prefHeight="356.0" prefWidth="220.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.171" fx:controller="VinnieMotorParts.VinnieAutoShopFXMLController">
<children>
<Label layoutX="10.0" layoutY="14.0" text="Routine Services">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<Label layoutX="10.0" layoutY="167.0" text="Non-routine Services">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<CheckBox fx:id="oilChangeCB" layoutX="24.0" layoutY="42.0" mnemonicParsing="false" text="Oil Change: $35" />
<CheckBox fx:id="lubeJobCB" layoutX="24.0" layoutY="69.0" mnemonicParsing="false" text="Lube Job: $25" />
<CheckBox fx:id="batteryCB" layoutX="24.0" layoutY="96.0" mnemonicParsing="false" text="Battery Replacement: $80" />
<CheckBox fx:id="tireCB" layoutX="24.0" layoutY="123.0" mnemonicParsing="false" text="Tire Rotation: $20" />
<Separator layoutX="10.0" layoutY="155.0" prefWidth="200.0" />
<Label layoutX="10.0" layoutY="200.0" text="Hours for parts?" />
<TextField fx:id="hrsPartsField" layoutX="110.0" layoutY="196.0" prefHeight="25.0" prefWidth="94.0" />
<Button fx:id="calculateButton" layoutX="59.0" layoutY="278.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="94.0" text="Calculate" />
<Label layoutX="13.0" layoutY="322.0" text="Total Cost" />
<TextField fx:id="totalCostField" editable="false" layoutX="113.0" layoutY="318.0" prefHeight="25.0" prefWidth="94.0" />
<Separator layoutX="10.0" layoutY="264.0" prefWidth="200.0" />
<Label layoutX="10.0" layoutY="232.0" text="Hours for labor?" />
<TextField fx:id="hrsLaborField" layoutX="110.0" layoutY="228.0" prefHeight="25.0" prefWidth="94.0" />
</children>
</AnchorPane>

VinnieAutoShopFXMLController.java

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javax.swing.JOptionPane;

public class VinnieAutoShopFXMLController implements Initializable {

@FXML
private CheckBox oilChangeCB;
@FXML
private CheckBox lubeJobCB;
@FXML
private CheckBox batteryCB;
@FXML
private CheckBox tireCB;
@FXML
private Button calculateButton;
@FXML
private TextField totalCostField;
@FXML
private TextField hrsPartsField;
@FXML
private TextField hrsLaborField;
  
private static final double OIL_CHANGE = 35;
private static final double LUBE_JOB = 25;
private static final double BATTERY_REPLACE = 80;
private static final double TIRE_ROTATION = 20;
private static final double PER_HOUR = 60;
  
public void calculateButtonAction()
{
calculateButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
if(hrsPartsField.getText().equals("") || hrsLaborField.getText().equals(""))
{
JOptionPane.showMessageDialog(null, "Please enter values for the parts and labor.");
return;
}
  
double oilChange = 0.0, lubeJob = 0.0, batteryReplace = 0.0, tireRotation = 0.0;
if(oilChangeCB.isSelected())
oilChange = OIL_CHANGE;
if(lubeJobCB.isSelected())
lubeJob = LUBE_JOB;
if(batteryCB.isSelected())
batteryReplace = BATTERY_REPLACE;
if(tireCB.isSelected())
tireRotation = TIRE_ROTATION;
  
double hrsParts = Double.parseDouble(hrsPartsField.getText().trim());
double hrsLabor = Double.parseDouble(hrsLaborField.getText().trim());
  
double totalCost = (oilChange + lubeJob + batteryReplace + tireRotation) +
(hrsParts * PER_HOUR) + (hrsLabor * PER_HOUR);
  
totalCostField.setText(String.format("%,.2f", totalCost));
}
});
}
  
@Override
public void initialize(URL url, ResourceBundle rb) {
calculateButtonAction();
}
}

VinnieAutoShop.java (Main class)

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class VinnieAutoShop extends Application{

@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("VinnieAutoShopFXML.fxml"));
Scene scene = new Scene(root);
stage.setTitle("Vinni's Auto Shop");
stage.setScene(scene);
stage.show();
}
  
public static void main(String[] args) {
launch(args);
}
}

*********************************************************** SCREENSHOT *****************************************************

Vinnis... - O X Routine Services ✓ Oil Change: $35 Lube Job: $25 ✓ Battery Replacement: $80 Tire Rotation: $20 Non-routine S

Add a comment
Know the answer?
Add Answer to:
Lab Chapter 12 Vinnie's Auto Shop performs the following routine maintenance services: • Oil change: $35.00...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Joe’s Automotive Joe’s Automotive performs the following routine maintenance services: • Oil chan...

    Need the answer in CSharp programming not java. Joe’s Automotive Joe’s Automotive performs the following routine maintenance services: • Oil change—$26.00 • Lube job—$18.00 • Radiator flush—$30.00 • Transmission flush—$80.00 • Inspection—$15.00 • Muffler replacement—$100.00 • Tire rotation—$20.00 Joe also performs other nonroutine services and charges for parts and labor ($20 per hour). Create an application that displays the total for a customer’s visit to Joe’s. The form should resemble the one shown in Figure 6-28 . Figure 6-28 Automotive...

  • I need help creating a code for the problem in Python. Joe's Automotive Joe's Automotive performs the following routine maintenance services: Oil change-$30.00 . Lube job-$20.00 Radiator flus...

    I need help creating a code for the problem in Python. Joe's Automotive Joe's Automotive performs the following routine maintenance services: Oil change-$30.00 . Lube job-$20.00 Radiator flush-$40.00 Transmission flush-$100.00 Inspection-$35.00 Muffler replacement-$200.00 Tire rotation- $20.00 Write a GUI program with check buttons that allow the user to select any or all of these services. When the user clicks a button, the total charges should be displayed Joe's Automotive Joe's Automotive performs the following routine maintenance services: Oil change-$30.00 ....

  • AA. Final Project - Improved JavaFX GUI Personal Lending Library Description: In this project we will...

    AA. Final Project - Improved JavaFX GUI Personal Lending Library Description: In this project we will improve our personal lending library tool by (1) adding the ability to delete items from the library, (2) creating a graphical user interface that shows the contents of the library and allows the user to add, delete, check out, or check in an item. (3) using a file to store the library contents so that they persist between program executions, and (4) removing the...

  • Create a program that performs the following operations: 1. Prompt for and accept a string of...

    Create a program that performs the following operations: 1. Prompt for and accept a string of up to 80 characters from the user. • The memory buffer for this string is created by: buffer: .space 80 #create space for string input The syscall to place input into the buffer looks like: li $v0,8 # code for syscall read_string la $a0, buffer #tell syscall where the buffer is li $a1, 80 # tell syscall how big the buffer is syscall 2....

  • i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due...

    i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT