否则没有错误

时间:2016-10-04 04:52:07

标签: java saas

我收到else without if错误。谁能告诉我这是什么问题?

import java.util.Scanner;

class Atm {
    public static void main(String[] args) {
        int expin = 1234;
        int bal = 25000;
        int enpin, amt;
        System.out.println("WELCOME TO VV BANK");
        System.out.println("ENTER THE PIN");
        Scanner scn = new Scanner(System.in);
        enpin = scn.nextInt();

        if (enpin == expin) {
            System.out.println("ENTER THE AMOUNT");
            amt = scn.nextInt();

            if (amt < bal) {    
                bal = bal - amt;
                System.out.println("The new balance is" + bal);
            } else {
                System.out.println("insufficient balance");
            }
        } else {
            System.out.println("Invalid pin");
        }

        System.out.println("Thank u for using ATM");
    }
}

0 个答案:

没有答案