Answered step by step
Verified Expert Solution
Question
1 Approved Answer
8.24 LAB: Metricized Fuel American gas-powered cars report their efficiency using the ratio of miles travelled per gallon of gas burned (MPG) Canadian cars instead
8.24 LAB: Metricized Fuel American gas-powered cars report their efficiency using the ratio of miles travelled per gallon of gas burned (MPG) Canadian cars instead report liters burned per 100 kilometers travelled (L/100km). Write a method named mpgToLkm that takes a double as a parameter, representing an MPG value, and returns a double that represents the equivalent number in L/100km. Then, write a main program that takes a number of laps as an input, calls method mpgToLkm() to calculate the Canadian equivalent, and outputs the L/100km amount. Steps to do the conversion: (1) calculate 1/mpg to get gallons per mile instead of miles per gallon. (2) multiply by liters-per-gallon, 3.7854 (3) multiply by miles-per-100km, 62.14 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: 7.6 the output is 1.90 Ex: If the input is 2.2 the output is 0.55 The program must define and call a method: public static double mpgToLkm(double mpgValue) 3777842244726.qx3297 LAB ACTIVITY 8.24.1: LAB: Metricized Fuel 0/10 LabProgram.java Load default template. 1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 /* Define your method here / 6 7 public static void main(String[] args) { 8 /* Type your code here. Your code must call the method. 9 } 10 } 11
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