java中字符串输入错误

时间:2015-10-19 10:40:44

标签: java

当程序运行编译器丢弃语句下面的行时,我创建了一个类客户端并设置并获取我遇到此问题的每个参数"输入客户端名称"并显示"输入客户国民ID" 完整的代码假设已经创建了类

import java.util.Scanner;

public class Main {


    public static void main(String[] args) 
    {
        System.out.println("\t\t\t********************\t\t\t");
        System.out.println("\t\t\t*Simple Bank System*\t\t\t");
        System.out.println("\t\t\t********************\t\t\t");
        Client client=new Client();
        int accountNum=1;
        int sAccountNum=1;
        Bank bank=new Bank();
       CommercialClient ComClient=new CommercialClient();
       Account account=new Account();
       Scanner user_input= new Scanner(System.in);


       System.out.println("select your choice   \n"+"------------------------------\n"+"1-Create new accountt\n"+"2-display bank data\n"+"3-Exit\n");


       int x;

       x = user_input.nextInt();   
       while(x!=3)

       {    
       if(x!=1&&x!=2)

       {

           System.out.println("\t\t\tPlease enter correct choice !\t\t\t");
       }

       else

       {

           if(x==1)

           {

               System.out.println("chose the client type :\n\n"+"1-Client\n"+"2-Commercial Client\n");

               x = user_input.nextInt();   


               if(x!=1&&x!=2)

               {

                   System.out.println("\t\t\tPlease enter correct choice !\t\t\t");

               }

               else

               {

                   if(x==1)

                   {

                       String input;

                       System.out.println("\nEnter client name :");
                       System.out.flush();                   
                       input=user_input.nextLine();

                       client.setName(input);

                       System.out.println("Enter client nationa ID :");

                       input=user_input.nextLine();

                       client.setNationalID(input);

                       System.out.println("\nEnter client Address:");

                       input=user_input.nextLine();

                       client.setAddress(input);

                       System.out.println("\nEnter client phone :");

                       input=user_input.nextLine();

                       client.setPhone(input);


                       System.out.println("\nchose the account type :\n\n"+"1-Normal account\n"+"2-Special account\n");

                       x = user_input.nextInt();

                       if(x!=1&&x!=2)

                       {
                           System.out.println("\t\t\tPlease enter correct choice !\t\t\t");


                        }

                       else

                       {

                           if(x==1)

                           {

                               System.out.println("Enter the beginning balance :");

                               x = user_input.nextInt();

                               account.setBalance(x);                                                            

                               account.setAcoount_Number(accountNum++);

                               client.setAccount(account);

                               bank.addAccount(account);

                               bank.addClient(client);

                           }

                           else 

                           {

                               System.out.println("Enter the beginning balance :");

                               x = user_input.nextInt();

                               account.setBalance(x);

                               account.setAcoount_Number(sAccountNum);

                               bank.addAccount(account);

                               bank.addClient(client);

                            }

                       }

                   }

                   else

                   {

                       String input;

                       System.out.println("\nEnter Commercial name :");

                       input=user_input.nextLine();

                       ComClient.setName(input);

                       System.out.println("Enter  Commercial ID :");

                       input=user_input.nextLine();

                       ComClient.setCommercialID(input);

                       System.out.println("\nEnter Commercial Address:");

                       input=user_input.nextLine();

                       ComClient.setAddress(input);

                       System.out.println("\nEnter Commercial phone :");

                       input=user_input.nextLine();

                       ComClient.setPhone(input);

                       System.out.println("chose the account type :\n\n"+"1-Normal account\n"+"2-Special account\n");

                       x = user_input.nextInt();

                       if(x!=1&&x!=2)

                       {

                           System.out.println("\t\t\tPlease enter correct choice !\t\t\t");

                       }

                             else

                       {

                           if(x==1)

                           {

                               System.out.println("Enter the beginning balance :");

                               account.setBalance(x);

                               account.setAcoount_Number(accountNum++);

                               bank.addAccount(ComClient.account);

                               bank.addClient(ComClient);

                            }

                                 else 

                           {

                               System.out.println("Enter the beginning balance :");

                               account.setBalance(x);

                               account.setAcoount_Number(sAccountNum);

                               bank.addAccount(account);

                               bank.addClient(ComClient);

                            }

                       }   

                   }

    }

           }

           else

           {

               bank.display();
               System.out.println("System closed");

           }

       }
        System.out.println("select your choice   \n"+"------------------------------\n"+"1-Create new accountt\n"+"2-display bank data\n"+"3-Exit\n");
        x = user_input.nextInt(); 
       }   
       System.out.println("System closed");
    }

}

0 个答案:

没有答案