+ 2

Could anyone write a java code to calculate the efficiency of a vehicle?

27th Mar 2019, 8:07 AM
Nihal Bhardwaj
Nihal Bhardwaj - avatar
6 Respostas
+ 26
Nihal Bhardwaj another thing, i leave a comment when and where i want it and not when and where you want it
27th Mar 2019, 11:21 AM
tooselfish
tooselfish - avatar
+ 19
Hello Nihal Bhardwaj no one here likes to do the homeworks for lazy people, have a nice day 👍😉
27th Mar 2019, 8:45 AM
tooselfish
tooselfish - avatar
+ 19
Nihal Bhardwaj it seems to me, you are the only one who is not able to code his own homeworks 👍😉
27th Mar 2019, 9:09 AM
tooselfish
tooselfish - avatar
+ 16
Hello, 😊 Please, if you want us to help you, then show us your attempt, what you don't understand exactly, where you are struggling, it will be much easier!👍😉  • SEARCH for similar QUESTIONS or ANSWERS before posting  • Include relevant TAGS  • https://www.sololearn.com/post/75089/?ref=app  • https://code.sololearn.com/WvG0MJq2dQ6y/
27th Mar 2019, 9:00 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 1
import java.util.Scanner; public class MagicNumber { public static void main(String[] args) { float AvgMPG = 0; int MilesDriven = 0; int totalTrips = 0; int GallonsUsed = 0; int totalMilesPerGallon = 0; int MilesPerGallon = 0; Scanner input = new Scanner(System.in); System.out.println("Enter Miles Driven or -1 to quit: "); MilesDriven = input.nextInt(); System.out.println("Enter Gallons used to fill tank or -1 to quit: "); GallonsUsed = input.nextInt(); while ( MilesDriven != -1) { MilesPerGallon = MilesDriven / GallonsUsed; System.out.println("Miles Per Gallon for this trip: " +MilesPerGallon); totalMilesPerGallon = MilesPerGallon + totalMilesPerGallon; totalTrips = totalTrips + 1; System.out.println("Enter Miles Driven or -1 to quit: "); MilesDriven = input.nextInt(); System.out.println("Enter Gallons used to fill tank or -1 to quit: "); GallonsUsed = input.nextInt(); } if (totalTrips != 0) { System.out.println("Number of trips taken: "+ totalTrips); AvgMPG = (float) totalMilesPerGallon / totalTrips; System
27th Mar 2019, 9:10 AM
Nihal Bhardwaj
Nihal Bhardwaj - avatar
0
This was my code
27th Mar 2019, 9:10 AM
Nihal Bhardwaj
Nihal Bhardwaj - avatar