What's new

Closed Java programming need help

Status
Not open for further replies.

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

50981740_348574335869789_4085569330874417152_n.jpg
 
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"));
       }}
 
Last edited:
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"));
       }}
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 to

private final static double LITER = 0.264179;
private final static double PRICE = 53.03;
 
Status
Not open for further replies.

Similar threads

Back
Top