Advertisement
_MuradPro_

BankMurad

Sep 9th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. package MuradHomeWork;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Bank {
  6.  
  7.     public static void main(String[] args) {
  8.         String ownerName;
  9.         double balance;
  10.        
  11.         Scanner in = new Scanner(System.in);
  12.         Account account1 = new Account(123,"Murad", 100);
  13.         account1.deposit(145.9);
  14.        
  15.        
  16.        
  17.         Account accounts[] = new Account[5];
  18.         for(int i=0; i<2; i++){
  19.             System.out.println("Please enter your name");
  20.             ownerName = in.next();
  21.             System.out.println("Please put money in your start balance");
  22.             balance = in.nextDouble();
  23.             accounts[i] = new Account(i+1, ownerName , balance);
  24.         }
  25.        
  26.        
  27.         System.out.println("Please enter the number of your account");
  28.         int accountNumCheck = in.nextInt();
  29.         System.out.println("Please enter the name of your account");
  30.         String ownerNameCheck = in.next();
  31.         boolean accountCheck = true;
  32.         for(int i=0; i<2; i++) {
  33.             if(accountNumCheck == accounts[i].getAccountNum() && ownerNameCheck.equals(accounts[i].getOwnerName())) {
  34.                 accountCheck = true;
  35.                 System.out.println("Your balance is " + accounts[i].getBalance());
  36.                 break;
  37.             }
  38.             else
  39.                 accountCheck = false;
  40.             }
  41.        
  42.         if(accountCheck == false)
  43.             System.out.println("Error");
  44.         }
  45.            
  46.     }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement