The CEO of Flint Hills Motors FHM would like you to create a
The CEO of Flint Hills Motors (FHM) would like you to create an order processing system project that will determine the total amount due from a customer for the purchase of a vehicle. The program must permit the user to input the base price, select zero or one or more accessories (stereo system costing $234.00, leather interior costing $1040.00, GPS costing $450.00), and select an exterior finish (standard finish costing $0.00, superior finish costing $799.00, executive finish costing $999.00). The total price is the sum of the base price, accessories price and exterior finish price. The sales tax depends on the state in which the vehicle will be registered; for California, New York, and Alaska it is 12% of the total price; for all other states it is 8% of the total price.
The trade-in allowance depends on the year of manufacture of the vehicle and the state in which it had been registered at initial purchase. FHM does not accept vehicles manufactured earlier that 1990 for trade-in allowance. For vehicles manufactured between 1990 and 1999 and initially registered in Illinois, Indiana, Iowa, Kansas, Michigan, Minnesota, Missouri, or Nebraska, the trade-in allowance is $3000.00, for all other states it is $ 2750.00. For vehicles manufactured between 2000 and 2009 and initially registered in Illinois, Indiana, Iowa, Kansas, Michigan, Minnesota, Missouri, Nebraska, North Dakota, Ohio, South Dakota or Wisconsin, the trade-in allowance is $3250.00, for all other states it is $ 3000.00. For vehicles manufactured in 2010 and after, the trade-in allowance is $5000.00, irrespective of the state of initial registration.
Total amount due = (Total price + Sales tax) – Trade-in allowance.
You are in charge of developing an order processing software program using Java. The program must receive appropriate input from the user including customer name and address. It must display the pricing details in a text area having scroll bars.
I just need you to give me the input objects, and the output objects
Solution
Stored all the information in Customer Object , which you can use and pass to any method
//-------------------------- Customer Class --------------------------------------------------
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;
class Customer {
private String name;
private String address;
private double basePrice;
private HashMap<String, Double> accessoriesList = new HashMap<>();
private double accessoriesPrice;
private String exteriorFinish;
private Double exteriorFinishPrice;
private String state;
private double saleTax;
private int manufacturingYear;
private boolean allowanceAllowed;
private double allowanceAmount;
private double totalPrice;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public double getBasePrice() {
return basePrice;
}
public void setBasePrice(double basePrice) {
this.basePrice = basePrice;
}
public HashMap<String, Double> getAccessoriesList() {
return accessoriesList;
}
public double getAccessoriesPrice() {
return accessoriesPrice;
}
public void setAccessoriesPrice(double accessoriesPrice) {
this.accessoriesPrice = accessoriesPrice;
}
public String getExteriorFinish() {
return exteriorFinish;
}
public void setExteriorFinish(String exteriorFinish) {
this.exteriorFinish = exteriorFinish;
}
public Double getExteriorFinishPrice() {
return exteriorFinishPrice;
}
public void setExteriorFinishPrice(Double exteriorFinishPrice) {
this.exteriorFinishPrice = exteriorFinishPrice;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public double getSaleTax() {
return saleTax;
}
public void setSaleTax(double saleTax) {
this.saleTax = saleTax;
}
public int getManufacturingYear() {
return manufacturingYear;
}
public void setManufacturingYear(int manufacturingYear) {
this.manufacturingYear = manufacturingYear;
}
public boolean isAllowanceAllowed() {
return allowanceAllowed;
}
public void setAllowanceAllowed(boolean allowanceAllowed) {
this.allowanceAllowed = allowanceAllowed;
}
public double getTotalPrice() {
return totalPrice;
}
public void setTotalPrice(double totalPrice) {
this.totalPrice = totalPrice;
}
public double getAllowanceAmount() {
return allowanceAmount;
}
public void setAllowanceAmount(double allowanceAmount) {
this.allowanceAmount = allowanceAmount;
}
@Override
public String toString() {
return \"Customer [name=\" + name + \", address=\" + address + \", basePrice=\" + basePrice + \", accessoriesList=\"
+ accessoriesList + \", accessoriesPrice=\" + accessoriesPrice + \", exteriorFinish=\" + exteriorFinish
+ \", exteriorFinishPrice=\" + exteriorFinishPrice + \", state=\" + state + \", saleTax=\" + saleTax
+ \", manufacturingYear=\" + manufacturingYear + \", allowanceAllowed=\" + allowanceAllowed
+ \", allowanceAmount=\" + allowanceAmount + \", totalPrice=\" + totalPrice + \"]\";
}
}
// -------------------------- FHM class ------------------------------------
public class FHM {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Customer cus = new Customer();
// name
System.out.println(\"Enter name\");
cus.setName(sc.nextLine());
// address
System.out.println(\"Enter the address\");
cus.setAddress(sc.nextLine());
// base Price
System.out.println(\"Enter the base Price\");
cus.setBasePrice(sc.nextDouble());
// accessories
System.out.println(\"Select zero,one or more accessories\");
HashMap<String, Double> accessoriesList = new HashMap<>();
accessoriesList.put(\"stereo system\", 234.00);
accessoriesList.put(\"leather interior\", 1040.00);
accessoriesList.put(\"GPS\", 450.00);
double accessoriesPrice = 0d;
for (Entry<String, Double> e : accessoriesList.entrySet()) {
System.out.println(e.getKey() + \" y/n ?\");
char yes = sc.next().charAt(0);
if (yes == \'Y\' || yes == \'y\') {
accessoriesPrice += e.getValue();
cus.getAccessoriesList().put(e.getKey(), e.getValue());
}
}
cus.setAccessoriesPrice(accessoriesPrice);
// Exterior Finish
System.out.println(\"select an exterior finish: \");
System.out.println(\"1.standard finish costing $0.00\" + \"\ 2.superior finish costing $799.00\"
+ \"\ 3.executive finish costing $999.00). \");
int exteriorFinishChoice = sc.nextInt();
double exteriorFinishPrice = 0d;
switch (exteriorFinishChoice) {
case 1:
cus.setExteriorFinish(\"Standard Finish\");
exteriorFinishPrice = 0.00;
break;
case 2:
cus.setExteriorFinish(\"Superior finish\");
exteriorFinishPrice = 799.00;
break;
case 3:
cus.setExteriorFinish(\"Executive finish\");
exteriorFinishPrice = 999.00;
break;
}
cus.setExteriorFinishPrice(exteriorFinishPrice);
cus.setTotalPrice(cus.getBasePrice() + cus.getAccessoriesPrice() + cus.getExteriorFinishPrice());
// State
System.out.println(\"Enter registered state\");
sc.nextLine();
cus.setState(sc.nextLine().toLowerCase());
// Sale Tax
List<String> stateList = new ArrayList<String>();
stateList.add(\"alaska\");
stateList.add(\"new York\");
stateList.add(\"california\");
if (stateList.contains(cus.getState())) {
cus.setSaleTax(0.12);
} else {
cus.setSaleTax(0.08);
}
cus.setTotalPrice((1 + cus.getSaleTax()) * cus.getTotalPrice());
// Allowance allowed
System.out.println(\"Enter year of registration\");
cus.setManufacturingYear(sc.nextInt());
List<String> allowanceStateList90s = new ArrayList<String>();
allowanceStateList90s.add(\"illinois\");
allowanceStateList90s.add(\"indiana\");
allowanceStateList90s.add(\"iowa\");
allowanceStateList90s.add(\"kansas\");
allowanceStateList90s.add(\"michigan\");
allowanceStateList90s.add(\"minnesota\");
allowanceStateList90s.add(\"missouri\");
allowanceStateList90s.add(\"nebraska\");
List<String> allowanceStateList20s = new ArrayList<String>();
allowanceStateList20s.addAll(allowanceStateList90s);
allowanceStateList20s.add(\"north Dakota\");
allowanceStateList20s.add(\"ohio\");
allowanceStateList20s.add(\"south Dakota\");
allowanceStateList20s.add(\"wisconsin\");
if (cus.getManufacturingYear() >= 1990 && cus.getManufacturingYear() <= 1999) {
cus.setAllowanceAllowed(true);
if (allowanceStateList90s.contains(cus.getState())) {
cus.setAllowanceAmount(3250.00);
} else {
cus.setAllowanceAmount(3000.00);
}
}
else if (cus.getManufacturingYear() >= 2000 && cus.getManufacturingYear() <= 2009) {
cus.setAllowanceAllowed(true);
if (allowanceStateList20s.contains(cus.getState())) {
cus.setAllowanceAmount(3000.00);
} else {
cus.setAllowanceAmount(2750.00);
}
}
else if (cus.getManufacturingYear() >= 2010) {
cus.setAllowanceAllowed(true);
cus.setAllowanceAmount(5000.00);
}
else {
cus.setAllowanceAllowed(false);
cus.setAllowanceAmount(0.00);
}
System.out.println(cus);
}
}




