DAT/210 Week 2 Java LAB 3.18: Driving costs

$ 7

DAT/210 Week 2 Java LAB 3.18: Driving costs

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 20 miles, 75 miles, and 500 miles.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
System.out.printf(“%.2f”, yourValue);
The output ends with a newline.

Ex: If the input is:
20.0 3.1599
the output is:
3.16 11.85 79.00

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

import java.util.Scanner;

public class LabProgram {
public static void main(String() args) {
/* Type your code here. */
}
}

929 in stock

SKU: DAT210WK2LAB3P18 Category:

Description

DAT/210 Week 2 Java LAB 3.18: Driving costs

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 20 miles, 75 miles, and 500 miles.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
System.out.printf(“%.2f”, yourValue);
The output ends with a newline.

Ex: If the input is:
20.0 3.1599
the output is:
3.16 11.85 79.00

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

import java.util.Scanner;

public class LabProgram {
public static void main(String() args) {
/* Type your code here. */
}
}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.