Question: Create a Java program that does the following: Prompts the user for the number of cars they had on hand and how many they sold

Create a Java program that does the following:

  • Prompts the user for the number of cars they had on hand and how many they sold and saves this information.
  • Prompts the user for the average price per car and saves this information
  • Prompts the user for the local tax amount
  • Prompts the user for the amount it costs to store unsold cars
  • Prints the following:

Cars Sold = XXX

Cars Left = XXX

Total made on sold cars minus tax amount = XXX

Total cost storing unsold cars = XXX

Note** When you use the kbd object to read remember that you will have to read to the end of the line or the buffer will still contain data.

For example: String name;

int total;

double price;

name = kbd.nextLine(); total = kbd.nextInt(); kbd.nextLine(); <-- must use another nextLine() to clear the buffer price=kbd.nextDouble();

Upload just the Java code. Do not upload the entire Project. You can cut and paste the code into the Assignment Text box.

The example programs in the lectures use a special set of command to easily read data from the keyboard. This consist of

  1. At the top of the program add import.java.util.*;
  2. Right below the Public Class line enter static Scanner kbd;
  3. The first line in main() should be kbd = new Scanner(System.in);

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 Databases Questions!