有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么我的变量不能工作?

我在做一个银行,我在做一个扫描器选项,所以如果你按1,你可以取款,如果你按2,你将添加钱,3用于离开银行。但当我按2或3时,它没有任何作用,我尝试了其他方法,但如果我得到更多错误,我不知道区别

----注------ 我尝试了取消嵌套(如果这是一个短语),但在按钮附近的其他地方(我已经标记了位置)出现语法错误,所以我不确定如何修复

import java.util.Scanner;




public class Bank {




    public static void main (String [] args) {
     System.out.println("Welcome To Harry's Bank");


    //Pin System
        System.out.println("Please Enter Your Bank Pin.");
    Scanner userInput = new Scanner (System.in);
        int number;
        int password = 7123;
        int amount = 4000;

        number = userInput.nextInt();

        if (number == password) {
        System.out.println("Pin Accepted");
        System.out.println("You Have Now Entered Harry's Bank!");
        System.out.println("Press The Number Of The Option You Would Like.");
        System.out.println("1.Withdraw Money.");
        System.out.println("2.Put In Money");
        System.out.println("3.Exit Bank");
        Scanner Options = new Scanner (System.in);
        int option;
        option = userInput.nextInt();

        if (option == 1) {
        //Withdraw Money System
        System.out.println("You Have £4000");
        System.out.println("How Much Would You Like To Take Out?");
        Scanner Input = new Scanner (System.in);
        int numbere;


        numbere = userInput.nextInt();
        if (numbere < 4000) {

        int money = amount - numbere;
            System.out.println("You Have Now £" + money);
            System.out.println("Thank You For Banking At Harry's Bank!");
            System.out.println("Please Come Again!");
          }else{
                System.out.println("You Do Not Have Enough Money!"); 
          }
        }


        else if (option == 2) {
            //AddMoney System
            Scanner AddMoney = new Scanner (System.in);
            int AddMoney1;
            AddMoney1 = userInput.nextInt();
            int NewMoney = (amount + AddMoney1);
            System.out.println("How Much Would You Like To Enter?");
            System.out.println("You Now Have " + NewMoney + "!");
            System.out.println("Thank You For Using Harry's Bank!");




        }
        else if (option == 3) {
            System.out.println("");
            System.out.println("");
            System.out.println("");
            System.out.println("");
            System.out.println("");
            System.out.println("");
            System.out.println("");
            System.out.println("Goodbye!");
        }
        }else{
            System.out.println("Next Time Only Press 1,2 or 3!");
        }
         //error Here For Else "Syntax error on token "else", { expected"
        }else{
                System.out.println("Pin Declined!");

          }



            }








        }

共 (0) 个答案