Page 277 - ComputerScience_Class_11
P. 277

15              do    {

                                       System.out.print("Enter the balance amount in the account (minimum
                  16                     amount 1000/-) : ");
                  17                  bal=sc.nextInt();
                  18              }while(bal<1000);

                  19          }
                  20          void deposit(int d)    {
                  21              bal+=d;
                  22          }

                  23          void withdraw(int w)    {
                  24              int temp=bal-w;
                  25              if(temp<1000)
                  26                  System.out.println("Minimum balance should be 1000 rupees");
                  27              else

                  28                  bal=temp;
                  29          }
                  30          void print()    {
                  31              System.out.println("Customer Name:"+cus_name);
                  32              System.out.println("Account No.:"+acno);

                  33              System.out.println("Balance:"+bal);
                  34              System.out.println("Type of Account:"+type_acc);
                  35          }
                  36          public static void main(String args[])    {
                  37              Scanner sc=new Scanner(System.in);

                  38              Banking_system ob=new Banking_system();
                  39              ob.input();
                  40              char c; int amt;
                  41              System.out.println("Enter (D)eposit/(W)ithdraw:");

                  42              c=sc.next().charAt(0);
                  43              if(c=='D')    {
                  44                  System.out.println("Enter the amount to deposit:");
                  45                  amt=sc.nextInt();
                  46                  ob.deposit(amt);
                  47              }

                  48              else if(c=='W')    {
                  49                  System.out.println("Enter the amount to withdraw:");
                  50                  amt=sc.nextInt();
                  51                  ob.withdraw(amt);

                  52              }




                                                                                           Methods and Constructors  275
   272   273   274   275   276   277   278   279   280   281   282