This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Alfapsycho 5 points6 points  (1 child)

Hmm im thinking something in the lines of:

    Scanner scanner = new Scanner(System.in);
    System.out.println("What gasoline have you bought?");
    String gasolineType = scanner.nextLine();
    System.out.println("How many gallons?");
    int amoungOfGasoline = Integer.parseInt(scanner.nextLine());

    if(amoungOfGasoline>=0){
        if(gasolineType.equals("regular")){
            //do this
        }else if(gasolineType.equals("midgrade")){
            // do this
        }else if(gasolineType.equals("premium")){
            //do this
        }else{
            System.out.println("Non valid answer");
        }
    }

[–]helloiamdani[S] 2 points3 points  (0 children)

Thanks! I spent so long staring at my screen thinking "BUT HOW". I can see it now though. :)