Natnatfogee
Honorary Poster
- Joined
- May 26, 2018
- Posts
- 543
- Reaction
- 134
- Points
- 226
- Age
- 24
need help mga sir kung pano iexecute etong task na ito sa java ide
package gallons.program;
import java.util.Scanner;
public class GallonsProgram { // Change it base on your own Class
private final static double LITER = 0.264179;
private final static double PRICE = 53.03;
private static double milesPerGallon(int miles, int liter){
double gallons = LITER*liter;
return (miles/gallons);
}
private static double PricePerLiter(int liter){
return (PRICE * liter);
}
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
String choice="N";
int mile,liter;
do{
System.out.println("Enter the number of Liters of gasoline: ");
liter = input.nextInt();
System.out.println("Enter the number of miles traveled by the car: ");
mile = input.nextInt();
System.out.printf("Number of miles per gallon: %.3f%n",milesPerGallon(mile, liter));
System.out.printf("Price: PHP%.2f%n",PricePerLiter(liter));
System.out.println("To Continue, Enter Y");
choice = input.next();
} while(choice.equals("Y") || choice.equals("y"));
}}
thanks a lot sir!Hopes this helps
Code:package gallons.program; import java.util.Scanner; public class GallonsProgram { // Change it base on your own Class private final static double LITER = 0.264179; private final static double PRICE = 53.03; private static double milesPerGallon(int miles, int liter){ double gallons = LITER*liter; return (miles/gallons); } private static double PricePerLiter(int liter){ return (PRICE * liter); } static Scanner input = new Scanner(System.in); public static void main(String[] args) { String choice="N"; int mile,liter; do{ System.out.println("Enter the number of Liters of gasoline: "); liter = input.nextInt(); System.out.println("Enter the number of miles traveled by the car: "); mile = input.nextInt(); System.out.printf("Number of miles per gallon: %.3f%n",milesPerGallon(mile, liter)); System.out.printf("Price: PHP%.2f%n",PricePerLiter(liter)); System.out.println("To Continue, Enter Y"); choice = input.next(); } while(choice.equals("Y") || choice.equals("y")); }}
boss question lang pano nyo po tinawag tong code na toHopes this helps
Code:package gallons.program; import java.util.Scanner; public class GallonsProgram { // Change it base on your own Class private final static double LITER = 0.264179; private final static double PRICE = 53.03; private static double milesPerGallon(int miles, int liter){ double gallons = LITER*liter; return (miles/gallons); } private static double PricePerLiter(int liter){ return (PRICE * liter); } static Scanner input = new Scanner(System.in); public static void main(String[] args) { String choice="N"; int mile,liter; do{ System.out.println("Enter the number of Liters of gasoline: "); liter = input.nextInt(); System.out.println("Enter the number of miles traveled by the car: "); mile = input.nextInt(); System.out.printf("Number of miles per gallon: %.3f%n",milesPerGallon(mile, liter)); System.out.printf("Price: PHP%.2f%n",PricePerLiter(liter)); System.out.println("To Continue, Enter Y"); choice = input.next(); } while(choice.equals("Y") || choice.equals("y")); }}
ginagamit yan ng method, tas yung method naman yung gagamitin ng userboss question lang pano nyo po tinawag tong code na to
private final static double LITER = 0.264179;
private final static double PRICE = 53.03;
salamat sir pwede malaman kung san banda sa code ipinasok un method?ginagamit yan ng method, tas yung method naman yung gagamitin ng user
ditosalamat sir pwede malaman kung san banda sa code ipinasok un method?