程序代写代做 compiler Java CS1341 – Lab 3 Programming Assignment Assignment Due Saturday, February 29, 2020 at 6:00 AM

CS1341 – Lab 3 Programming Assignment Assignment Due Saturday, February 29, 2020 at 6:00 AM
This assignment requires a Pre-Lab and a Lab.
Pre-Lab [10 POINTS]: Create a Java program called VolumeOfTriangularPrism which asks the user to enter the base, height, and length of the prism, stores the values in three double variables, calculates the volume of the cone using the base, height, and length, and displays the volume to the user.
Note: V = (base x height x length)/2
A sample output is provided below where user input is highlighted in yellow. Sample output
Enter the following values in centimeters –
Base of the triangle: 19
Height of the triangle: 24
Length of the prism: 47
For base = 19.00 cm, height = 24.00 cm, and length = 47.00 cm, the volume of
the triangular prism: 10716.00 cm3
GRADING: Comment your program to explain your steps. Each program should compile without errors and should run to produce outputs described for each exercise. The following points will be discounted if the related element is missing or incorrect:
• Output formatting [2 points each]
• Proper names for classes, variables, and methods [1 point each]
• No Comments [5 points]
• Program doesn’t compile [5 points for each minor error up to 5 errors provided that after fixing
the errors the program compiles. If the program does not compiler after the 5 errors are fixed,
partial credit will be given not to exceed 50 points]
• Source code (java file) missing [ 15 points]
• Executable (class file) missing [15 points]
• Both java file and class file missing [100 points]
• Missing method where required [5 points each]
Submit the java and class files via Canvas (as a single zip-file). Include a comment block at the top of
each Java file that includes your name, student id number, and “Lab 3-Spring 2020”.

LAB [90 POINTS] Part I [15 POINTS]
Modify the pre-lab solution to use a method. Create a method called getVolume which accepts three parameters of type double called base, height, and length, calculates the volume of the prism, and returns it. Use the method in the VolumeOfTriangularPrism class as follows. In the main method, ask the user to enter the base, height, and length, store the values in three double variables, call the getVolume method passing variables to the method, and display the returned volume to the user.
Part II [75 POINTS]
Develop a menu-driven Java program for an online tire shop called Mustang Tires. The shop:
• sells tires available in its inventory
• allows the customer to choose a tire delivery option
• allows the customer to schedule a tire installation appointment
To accomplish this, you will create a Java class called MustangTires which will be structured as shown in the diagram. Utilize the method headers provided in the diagram below in your program.

Static variables will act as “global” variables and can be accessed directly from any method in the class; you will create the following variables before the main method and inside the class:
static Scanner scan = new Scanner(System.in);
static double total = 0.0;
static String invoice = “\nDescription\t\tQuantity\tAmount\n” + “————
————————————-\n”;
static double focusTirePrice = 59.99;
static double malibuTirePrice = 79.99;
static double rav4TirePrice = 99.99;
static double fiveSeriesTirePrice = 199.99;
static double deliveryOption1 = 0.0;
static double deliveryOption2 = 25.99;
static double deliveryOption3 = 50.99;
static double deliveryOption4 = 150.99;
static double morningInstallation = 89.99;
static double afternoonInstallation = 99.99;
In the main method, print a welcome message as follows: Welcome to Mustang Tires!
Then, inside a loop:
Call the displayMenu method which displays the menu options to the user and returns the menu option
the user has entered. The menu options are to be printed as follows:
Choose from the following options:
1) Purchase tires
2) Select a tire delivery option
3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option:
Check the option that the user has entered as follows:
• If the user enters 1, call the purchaseTires method which performs the following steps inside a loop:
o Calls the displayInventory method to print the following to the user:
Inventory Number Description Price Per Tire
———————————————————–
1 2 3 4
o
Ford Focus Tires
Chevy Malibu Tires
Toyota RAV4 Tires
BMW 5 Series Tires
$59.99
$79.99
$99.99
$199.99
Asks the user to enter an inventory number, stores the inventory number in an int variable called inventoryNum, asks the user for the quantity, and stores the value in an int variable called quantity.

o If the user input is correct for both the quantity and the inventory number,
– Call the calculateTiresPrice method passing it the inventory number and the
quantity to get the cost of the tires followed by a call to the updateTotal method passing it the cost of the tires to add to the total (more details on these methods are provided at the end)
– Update the invoice static variable as follows:
invoice += “\t” + quantity + “\t$” + tiresCost + “\n”;
– break
o Otherwise, display an error message to the user if the input is incorrect (i.e. quantity is
less than 1 or the inventory number does not exist) • If the user enters 2,
o o
• If the
• If the o o o
o
Call the getDeliveryOption method which prints the following to the user and returns the option the user has entered
Select from the following options:
———————————-
1) 5-7 days free shipping
2) 3-5 days at $25.99
3) Two-day shipping at $50.99
4) Next day shipping at $150.99
Delivery option:
Call the getDeliveryFee method passing it the delivery option. This method will return the delivery fee to the main method (more details below)
Call the updateTotal method passing it the delivery fee (more details below)
user enters 3, call the scheduleTireInstallation method (more details below)
user enters 4, call the displayInvoice method which
Prints the invoice static variable to the user
Calculates the tax off of the total
Displays the total before tax, the tax, and the total plus the tax to the user (see sample output at the end)
• If the user enters option 9, print the following to the user and break out of the loop to end the program:
You have successfully paid your invoice. Good-bye!
Additional Method Details
1) The calculateTiresPrice method accepts the inventoryNum and quantity and returns the quantity multiplied by the price. In the calculateTiresPrice method, perform the following steps:
• Declare a variable: double price = 0.0;

• If the inventoryNum is 1 then do the following:
o Update the invoice static variable and set the price variable to the correct price static
variable. Here’s an example:
invoice += “Ford Focus Tires\t”;
price = focusTirePrice;
• Repeat the same for inventoryNum 2, 3, and 4.
• Return the quantity multiplied by the price
2) The updateTotal method accepts a double variable called amount, updates the total by adding the amount to it and displays the current total to the user.
3) The getDeliveryFee method takes an int variable called deliveryOption as input and determines the deliveryFee based on the deliveryOption value and updates the invoice static variable. Here’s an example for deliveryOption equals to 1:
invoice += “5-7 days free shipping\t\t-\t$” + deliveryOption1 + “\n”;
deliveryFee = deliveryOption1;
4) The scheduleTireInstallation method performs the following steps:
• Prompts the user to enter the appointment number as follows: Would you like a morning or afternoon appointment? (1 = Morning, 2 = Afternoon, 3 = exit) Installation option:
• In a loop, check the user’s input:
o If the user enters 1, then
– display the following message (use the morningInstallation static variable to display the value):
Morning installations cost $89.99
– Call updateTotal passing it morningInstallation
– Update invoice
invoice += “Morning installation\t\t-\t$” + morningInstallation + “\n”;
– Break out of the loop
o If the user enters 2, repeat the same steps as option 1 using afternoonInstallation o If the user enters 3, the loops should end
o Otherwise, inform the user that they entered invalid input and ask them for input again
A sample output is provided below. User input is highlighted in yellow.
Welcome to Mustang Tires!
Choose from the following options:
1) Purchase tires
2) Select a tire delivery option

3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option: 7
Select an option from the following menu.
Choose from the following options:
1) Purchase tires
2) Select a tire delivery option
3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option: 1
Inventory Number Description
——————————————————–
1 Ford Focus Tires
2 Chevy Malibu Tires
3 Toyota RAV4 Tires
4 BMW 5 Series Tires
$59.99
$79.99
$99.99
$199.99
Enter the inventory number of the tires you want to purchase: 9
Enter the quantity: 7
Incorrect input.
Inventory number should be 1, 2, 3, or 4.
Inventory Number Description Price Per Tire
——————————————————–
1 Ford Focus Tires
2 Chevy Malibu Tires
3 Toyota RAV4 Tires
4 BMW 5 Series Tires
$59.99
$79.99
$99.99
$199.99
Enter the inventory number of the tires you want to purchase: 1
Enter the quantity: 0
Incorrect input.
Quantity should be greater than 0.
Inventory Number Description Price Per Tire
——————————————————–
Price Per Tire
1 Ford Focus Tires
2 Chevy Malibu Tires
3 Toyota RAV4 Tires
4 BMW 5 Series Tires
$59.99
$79.99
$99.99
$199.99
Enter the inventory number of the tires you want to purchase: 7
Enter the quantity: -1
Incorrect input.

Quantity should be greater than 0.
Inventory number should be 1, 2, 3, or 4.
Inventory Number Description Price Per Tire
——————————————————–
1 Ford Focus Tires
2 Chevy Malibu Tires
3 Toyota RAV4 Tires
4 BMW 5 Series Tires
$59.99
$79.99
$99.99
$199.99
Enter the inventory number of the tires you want to purchase: 1
Enter the quantity: 4
Your current total is: $239.96
Choose from the following options:
1) Purchase tires
2) Select a tire delivery option
3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option: 1
Inventory Number Description
——————————————————–
1 Ford Focus Tires
2 Chevy Malibu Tires
3 Toyota RAV4 Tires
4 BMW 5 Series Tires
$59.99
$79.99
$99.99
$199.99
Enter the inventory number of the tires you want to purchase: 4
Enter the quantity: 4
Your current total is: $1,039.92
Choose from the following options:
1) Purchase tires
2) Select a tire delivery option
3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option: 2
Select from the following options:
———————————-
1) 5-7 days free shipping
2) 3-5 days at $25.99
3) Two-day shipping at $50.99
4) Next day shipping at $150.99
Delivery option: 4
Your current total is: $1,190.91
Choose from the following options:
1) Purchase tires
Price Per Tire

2) Select a tire delivery option
3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option: 3
Would you like a morning or afternoon appointment?
(1 = Morning, 2 = Afternoon, 3 = exit)
Installation option: 3
Choose from the following options:
1) Purchase tires
2) Select a tire delivery option
3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option: 3
Would you like a morning or afternoon appointment?
(1 = Morning, 2 = Afternoon, 3 = exit)
Installation option: 6
Please try again. Would you like a morning or afternoon appointment?
(1 = Morning, 2 = Afternoon, 3 = exit)
Installation option: 1
Morning installations cost $89.99
Your current total is: $1,280.90
Choose from the following options:
1) Purchase tires
2) Select a tire delivery option
3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option: 4
Description Quantity Amount
——————————————-
Ford Focus Tires 4
BMW 5 Series Tires 4
Next day shipping –
Morning installation –
$239.96
$799.96
$150.99
$89.99
===========================================
Total: $1,280.90
Tax: $105.67
Total plus tax: $1,386.57
Choose from the following options:
1) Purchase tires
2) Select a tire delivery option
3) Schedule a tire installation option
4) View invoice
9) Pay and Exit Store
option: 9
You have successfully paid your invoice. Good-bye!