Thanks for helping me with my previous question guys. I wish if Ican rate you al
ID: 3616091 • Letter: T
Question
Thanks for helping me with my previous question guys. I wish if Ican rate you all as life savers, but the website doesn't allow it.Java Question:
A car's miles-per-gallon (MPG) can be calculated with thefollowing formula: MPG = Miles driven / Gallons of gas used Write a program that asks the user for the number of milesdriven and the gallons of gas used. It should calculate the car'sMPG and display the result on the screen.
Java Question:
A car's miles-per-gallon (MPG) can be calculated with thefollowing formula: MPG = Miles driven / Gallons of gas used Write a program that asks the user for the number of milesdriven and the gallons of gas used. It should calculate the car'sMPG and display the result on the screen.
Explanation / Answer
importjava.util.*; public class MPG { publicstatic void main(String[]args) { Scanner keyboard =new Scanner(System.in); double miles, gallons, result; System.out.println("How manymiles?"); miles = keyboard.nextDouble(); System.out.println("How manygallons?"); gallons = keyboard.nextDouble(); System.out.println("Your MPGis " + (miles/gallons)); } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.