Question
Car Purchase.java public class CarPurchase { //VERSION = 1.04; private final static String CAR_BRAND_1 = Lexus; private final static String CAR_BRAND_2 = Cadillac; private final
Car Purchase.java
public class CarPurchase { //VERSION = 1.04; private final static String CAR_BRAND_1 = "Lexus"; private final static String CAR_BRAND_2 = "Cadillac"; private final static String CAR_BRAND_3 = "Mercedes"; private final static int CASH_PREFERRED=50000; private String myCarChoice = null; private int myCashDeposit = 0; private int myCreditScore = 0; private boolean baseBallFan = false; /** * Show the available car brands at the dealership */ public void showCarBrands() { System.out.println(CAR_BRAND_1); System.out.println(CAR_BRAND_2); System.out.println(CAR_BRAND_3); } public String getMyCarChoice() { return myCarChoice; } public void setMyCarChoice(String myCarChoice) { this.myCarChoice = myCarChoice; } public int getMyCashDeposit() { return myCashDeposit; } public void setMyCashDeposit(int myCashDeposit) { this.myCashDeposit = myCashDeposit; } public int getMyCreditScore() { return myCreditScore; } public void setMyCreditScore(int myCreditScore) { this.myCreditScore = myCreditScore; } public boolean isBaseBallFan() { return baseBallFan; } public void setBaseBallFan(boolean baseBallFan) { this.baseBallFan = baseBallFan; } /** * Determines if buyer is qualified * @return */ public boolean isQualifiedBuyer() { boolean answer = false; if (myCreditScore > 700) { answer = true; } return answer; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("CarPurchase [myCarChoice="); builder.append(myCarChoice); builder.append(", myCashDeposit="); builder.append(myCashDeposit); builder.append(", myCreditScore="); builder.append(myCreditScore); builder.append(", baseBallFan="); builder.append(baseBallFan); builder.append("]"); return builder.toString(); } /* * Test Code below * */ public static void main(String[] args) { CarPurchase myCarPurchase = new CarPurchase(); myCarPurchase.showCarBrands(); //TODO remove line below System.out.println("Is qualified buyer is "+myCarPurchase.isQualifiedBuyer()); } }
For this assignment, I need you to update the attached code. In your IDE, create a class named CarPurchase and the copy the provided code to this class. This code should run as-is and Steps 1b and 1c are already coded. The class CarPurchase is provided. There is work to do in main(). Methods that are part of CarPurchase will need to me modified or added. Using the provided code (above), make the following additions/corrections. The following tasks need to be done in main() . Create a scanner object for the keyboard. Create an Instance of the CarPurchase object ( provided ) Call the showCarBrands() method for the CarPurchase object ( provided) The remaining steps are to be stored using variable names of your choosing. Prompt for a user to select a car type to purchase. The user must type the name of the car brand. Store this in a string variable. Use the scanner's next() method for this prompt. For testing purposes, we will assume that the input is properly cased. Pass this string to the setMyCarChoicemethod of the CarPurchase object. Prompt for the amount of cash to apply to this purchase. This is a whole number and needs to be stored in an integer . Pass this integer to the setMyCashDeposit method of the CarPurchase object. Prompt for a credit score and store in an integer. Prompt "Are you a baseball fan ? (true/false) and store in a boolean variable. The user must enter true or false. Pass this boolean to the setBassBallFan method of the CarPurchase object. Create a public void method called SalesNote() and code the following conditions to display the results below: If myCarChoice is CAR_BRAND_1 - display "Welcome to the Lexus Club!". If myCarChoice is CAR_BRAND_1 and baseBallFan is true - display "Ranger Fans get free valet parking!". If myCarChoice is CAR_BRAND_2 display "Welcome Cadillac fan!". If myCarChoice is CAR_BRAND_3 - display "Be aware that the 100,000 mile checkup is typically $10,000". If myCharChoice is not one of the 3 CAR_BRANDs, display "Not an authorized dealer". Modify the existing isQualifiedBuyer method as below. The existing code no longer applies. if myCashDeposit >= CASH_PREFERRED - return true if myCashDeposit =700 - return true Otherwise return false In main() - Call the SalesNote method of the CarPurchase object Call the isQualifiedBuyer method of the CarPurchase object and display it's result Close the scanner object. Work to avoid redundancy (duplicate compares and duplicate actions) where possible. Hint: Review how to compare Strings. An example of input/output. You need to test ALL possible conditions. Lexus Cadillac Mercedes Enter a Car Brand from the list above:Lexus Enter cash down payment amount:10000 Enter your credit score:707 Are your a baseball fan ? false Welcome to the Lexus Club! Qualified Buyer is true
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started