السلام عليكم ورحمة الله وبركاتة
هذا برنامج الصراف الالي يدخل فقط شخصين من خلال المصفوفة ولو سمحتوا
مساعدتي على ان يدخل اكثر من شخص عن طريق رسالة تخرج للمستخدم يحدد من خلالها عدد الاشخاص
package array2;
import java.util.Date;
//client_account.java
import javax.swing.JOptionPane;
public class client_account {
public static void main(String[] args) {
Account acc1=new Account(13,"Ali");
Account acc2=new Account(12,"Fahad",10000.3);
acc1.deposit(1500.3);
acc2.withdraw(200);
System.out.println("\n Name : "+acc1.getCustomer());
System.out.println("\tHis Balance = "+ acc1.getBalance());
System.out.println("\tthe date of the last transaction is : "
+ acc1.last_Transaction_Date);
System.out.println("\n Name : "+acc2.getCustomer());
System.out.println("\tHis Balance = "+ acc2.getBalance());
System.out.println("\tthe date of the last transaction is : "
+ acc2.last_Transaction_Date);
System.out.println();
}
}
class Account{
private int account_no;
private String customer_name;
private double balance;
Date last_Transaction_Date;
Account(int no,String name){
account_no=no;
customer_name=name;
}
Account(int no,String name,double amt){
account_no=no;
customer_name=name;
balance=amt;
}
void deposit(double amt) {
if (amt > 0) {
balance += amt;
last_Transaction_Date = new Date();
}
else
JOptionPane.showMessageDialog(null, "the deposit amount mustbe>0");
}
void withdraw(double amt) {
if (amt <= balance) {
balance -= amt;
last_Transaction_Date = new Date();
}
else
JOptionPane.showMessageDialog(null, "the withdraw amountmust be<=balance");
}
public double getBalance() {
return balance;
}
public String getCustomer() {
return customer_name;
}
}