Assignment
1. You are to write a simple program using Netbeans Java
IDE that consists of two classes. The program
will allow the user to place an order for a Tesla Model X
car.
2. Present the user with a menu selection for each option on the
site. We will use JOptionPane to generate different options for the
user. See the examples posted for how to use JOPtionPane.
3. Each menu will have multiple items each item will be in the
following format “Description,Price”. For example "Long Range,
84990". Where Long Range is the description of the item and 84990
is the price for that item
4. The ordering process will be done in 5 steps. See the Tesla
website for an example https://www.tesla.com/modelx/
Steps
1. Select the Car
2. Select Exterior
3. Select Interior
4. Select Autopilot
5. Enter Payment Info
a. Enter Customer Info
b. Enter Card Info
6. At the end of the process you will need to display a
confirmation receipt that shows the purchase made (Screen #7)
7. Next you can ask the user if they want to place a new order
(Screen #8)
8. Keep processing orders and displaying their receipts as long as
the user chooses to continue placing orders
9. Once the user selects not to place any more new orders you can
display the summary of all sales for the store.
Test Data
Customer
Car Type, Color, Wheels, Interior, Seat Layout, Autopilot
option
Homer Simpson
Performance, Red, 22” Onyx Black, Cream, 7 seats, Autopilot
Lisa Simpson
Long Range, Pearl White, 20" Silver Wheels, Black, Five Seat, No
Autopilot
Bart Simpson
Performance, Solid Black, 20" Two Tone Slipstream, Black and White,
Six Seat Interior, No Autopilot
Marge Simpson
Performance, Midnight Silver, 22" Onyx Black Wheels, Cream, Six
Seat Interior, No Autopilot
Order Total: $119,990.00
For All Customers
Phone: 9095554444
Email: @cpp.edu
Payment Card Name:
Payment card Number: 999999999999
Payment card Expiration: 09/20
Payment Card Security: 8888
Payment Card Zip: 91710
Customer
package GUI;
import javax.swing.*;
public class CarSales
{
public static void main(String st[])
{
double amount = 0;
String values[];
int pos[] = new int [6];
String selectCar[] = {"Long Range, 84990", "Performance, 104990"};
String exteriorColor[] = {"Pearl White, 0", "Solid Black, 1500",
"Midnight Silver, 1500", "Deep Blue, 1500", "Red, 2500"};
String interiorColor[] = {"Black, 0", "Black and White, 1500", "Cream, 1500"};
String layout[] = {"Five Seat Interior, 0", "Six Seat Interior, 6500",
"Seven Seat Interior, 3500"};
String wheels[] = {"20\" Silver Wheels, 0", "20\" Two Tone Slip Stream, 2000",
"22\" Onyx Black Wheels, 5500"};
String autoPilot[] = {"No Autopilot, 0", "Autopilot, 6000"};
int x = JOptionPane.showOptionDialog(null, "Returns the position of your " +
"choice on the array", "Click a button",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, selectCar, selectCar[0]);
values = selectCar[x].split(",");
amount += Double.parseDouble(values[1]);
pos[0] = x;
x = JOptionPane.showOptionDialog(null, "Returns the position of your " +
"choice on the array", "Click a button",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, exteriorColor, exteriorColor[0]);
values = exteriorColor[x].split(",");
amount += Double.parseDouble(values[1]);
pos[1] = x;
x = JOptionPane.showOptionDialog(null, "Returns the position of your " +
"choice on the array", "Click a button",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, interiorColor, interiorColor[0]);
values = interiorColor[x].split(",");
amount += Double.parseDouble(values[1]);
pos[2] = x;
x = JOptionPane.showOptionDialog(null, "Returns the position of your " +
"choice on the array", "Click a button",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, layout, layout[0]);
values = layout[x].split(",");
amount += Double.parseDouble(values[1]);
pos[3] = x;
x = JOptionPane.showOptionDialog(null, "Returns the position of your " +
"choice on the array", "Click a button",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, wheels, wheels[0]);
values = wheels[x].split(",");
amount += Double.parseDouble(values[1]);
pos[4] = x;
x = JOptionPane.showOptionDialog(null, "Returns the position of your " +
"choice on the array", "Click a button",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, autoPilot, autoPilot[0]);
values = autoPilot[x].split(",");
amount += Double.parseDouble(values[1]);
pos[5] = x;
int c = 1;
JOptionPane.showMessageDialog(null,"Tesla Inland Empire" +
"\n 300 Valley boulvard, pomona, ca" +
"\n\n Tasla Model X \n\n Thank you Homer, Simpson for your order" +
"\n\n =====================================" +
"\n Order ID: " + c + "\n Model X: " + selectCar[pos[0]] +
"\n Color: " + exteriorColor[pos[1]] +
"\n Wheel: " + wheels[pos[4]] +
"\n Interior: " + interiorColor[pos[2]] +
"\n Layout: " + layout[pos[3]] +
"\n Auto Pilot: " + autoPilot[pos[5]] +
"\n Order Total: " + amount);
}
}
Sample Output:
Assignment 1. You are to write a simple program using Netbeans Java IDE that consists of two...