Answered step by step
Verified Expert Solution
Link Copied!

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 #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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

Coordinating privacy office meetings.

Answered: 1 week ago