Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /* ==================================================
- Chapter 2: Syntax section A- conditional clause
- Ex7: Fuel Tank
- ===================================================
- */
- public class MyProgram {
- public static void main(String[] args) {
- //variables
- final double QUANTITY=0.15;
- int maxTank;
- int currentTank;
- Scanner s=new Scanner(System.in);
- //user input
- System.out.println("What is your max fuel tank? ");
- maxTank=s.nextInt();
- System.out.println("How much fuel you have now? ");
- currentTank=s.nextInt();
- //check if refuel is needed and display message
- if(maxTank*QUANTITY >= currentTank)
- System.out.println("Go to a nearby gas station to refuel");
- else
- System.out.println("you can drive!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment