Question: I need help writing a Java program to calculate the light years per gallon for a trip in which a spaceship traveled 2 million light

I need help writing a Java program to calculate the light years per gallon for a trip in which a spaceship traveled 2 million light years on 15,000 gallons of space gas. The program should print the number of light years travelled, the number of gallons used and the light years per gallon. Light years per gallon should be printed as a number containing a decimal point. Light years and gallons should both be printed as integers.

Be sure to compute the light years per gallon in the program using an arithmetic calculation. The formula for light years per gallon is: Light-Years-Per-Gallon = Light-Years / Gallons Include your name and the title of the homework assignment (Homework 1) as comments at the top of your program.

Run your program. Your program must run successfully to receive full credit for this homework.

The output of the program should look like below.

Light Years: 2000000

Gallons: 15000

Light Years Per Gallon: 133.3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!