🔒 Closed Java programming need help

Status
Not open for further replies.

Natnatfogee

Honorary Poster
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"));
       }}
 
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.

About this Thread

  • 6
    Replies
  • 653
    Views
  • 3
    Participants
Last reply from:
Arcturus

Trending Topics

Online now

Members online
1,038
Guests online
938
Total visitors
1,976

Forum statistics

Threads
2,274,901
Posts
28,959,245
Members
1,233,482
Latest member
MyNameIsElga
Back
Top