Answer to Question #294538 in Java | JSP | JSF for Emonck

Question #294538

Develop a Java program for a car dealership shop that allows the dealer to enter the buying price of 5 cars and their models. the program then computes and displays the selling price and profit of each car the rate for selling price is 240% of buying price. Selling price = buying price * rate , profit = selling price - buying price .


1
Expert's answer
2022-02-06T12:30:34-0500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] models = new String[5];
        double[] prices = new double[models.length];
        for (int i = 0; i < models.length; i++) {
            System.out.println("Model:");
            models[i] = in.nextLine();
            System.out.println("Price:");
            prices[i] = Double.parseDouble(in.nextLine());
        }
        for (int i = 0; i < models.length; i++) {
            double sellingPrice = prices[i] * 2.4;
            System.out.println(models[i] + " Selling price: " + sellingPrice + "; Profit: "
                    + (sellingPrice - prices[i]));
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS