Question: / / statement used to create a keyboard input connection import java.until.Scanner; public class Program 1 { / / Main Function public static void main

// statement used to create a keyboard input connection
import java.until.Scanner;
public class Program1{
// Main Function
public static void main(String [] args)
{
// statement used to create a keyboard input connection
Scanner in = new Scanner(System.in);
// Prompt the user to input the price that they're willing to pay for their dream car in USD$
System.out.print("How much are you willing to pay for the car of your dreams in USD$?");
// User input for the price they're willing to pay for their dream car
double price = stdIn.nextDouble();
// Initialize discountRate variable and final price variable
double discountRate =0, finalPrice =0;
// Determine the discountRate based on the price using if, else if method
// first statement compares user's inputted price to 100,000. If it meets the criteria,then the corrisponding discount is used.
if (price >=100000)
{discountRate =0.30;}
//if the price does not meet the conditions of the if statement then price will be compared to the else if statement.
else if (price >=50000)
{discountRate =0.15;}
//if the price does not meet the criteria of the if statement or the else if statements above, then the price will be compared to the else statement. If the price does not meet the criteria of the if statement,else if statement,or else statement then no discount will be applied.
else
{discountRate =0.10;}
// Calculate the discountRate and final price
finalPrice = price-(price*discountRate);
// Display the result. The result includes the final output statement with calculated discountRate percentage and final price of user's dream car
System.out.printf("Wow, with your dicount of applied, you only owe Congrats!");
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!