Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Assignment First, launch NetBeans and close any previous projects that may

ID: 3875626 • Letter: J

Question

Java
Assignment


First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).


Then, create a new Java application called "DistanceCalc" (without the quotation marks) that requests two double values from the user at the command line:


amount of present fuel in gallons for the vehicle's fuel tank


the vehicle fuel efficiency (miles per gallon)


Compute how far, in miles, the vehicle can travel on the available fuel. Your program should output: "You are able to travel X.XX miles on remaining fuel." where X.XX is the miles distance you calculated. 


Explanation / Answer

Here is your DistanceCalc java application:

import java.util.Scanner;


public class DistanceCalc
{

  
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
double fuel,MilesPerGallon;
System.out.println("Enter present fuel(in gallons) in vehicle");
fuel=input.nextDouble(); //For user to enter fuel
System.out.println("Enter vehicle fuel efficiency(miles per gallon");
MilesPerGallon=input.nextDouble(); // For user to enter miles per gallons
System.out.println("You are able to travel "+fuel*MilesPerGallon+" miles on remaining fuel"); //To print the total miles can travel
}
  
}

I hope this solves your problem

Comment if you have any problem in above code

And please give it a thumbs up if it solved your problem :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote