Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 #: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:remainingdistance capacity distanceRate drivenDistance. If the remaining distance is less than kilometers, the program should output the followingmessage: Warning! The car must be refueled. Sample input output:Enter the capacity in liters of a cars fuel tank: Enter the KMliter that the car can be driven: Enter the distance already driven by the car: Capacity: KmLiters that the car can be driven: Distance already driven: The remaining kilometers: Submission: Save the project as HWEX
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