Create an Account

Already have account?

Forgot Your Password ?

Home / Questions / Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both dou

Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both dou

Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
System.out.printf("%.2f", yourValue);

Ex: If the input is:

the output is:

Note: Real per-mile cost would also include maintenance and depreciation.

Apr 07 2020 View more View Less

Answer (Solved)

question Subscribe To Get Solution

Related Questions