Question: Exercise # 2 :Write a program that does the following: Write a Java statement that imports the class Scanner. Write a Java statement that declares

Exercise #2:Write a program that does the following: Write a Java statement that imports the class Scanner. Write a Java statement that declares console to be a Scanner object for inputting data from thestandard input device. Write a Java statement that prompts the user to enter the capacity, in liters, of a cars fuel tankand store it in a variable named capacity. Write a Java statement that prompts the user to enter the kilometers per liter that the car can bedriven and store it in a variable named distanceRate. Write a Java statement that prompts the user to enter the distance already driven by the car andstore it in a variable named drivenDistance. The program outputs the capacity, the distanceRate, and the remaining number of kilometers thatthe car can be driven before the need to refuel again. The formula for the remaining kilometers is:remaining_distance =(capacity * distanceRate)- drivenDistance. If the remaining distance is less than 20 kilometers, the program should output the followingmessage: Warning! The car must be re-fueled. Sample input / output:Enter the capacity in liters of a cars fuel tank: 15 Enter the KM/liter that the car can be driven: 30 Enter the distance already driven by the car: 400******Capacity: 15.0Km/Liters that the car can be driven: 30.0 Distance already driven: 400.0The remaining kilometers: 50.0Submission: Save the project as HW2_EX2

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!