منتدى مصر التقني
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

تمارين بلغة الجافا ...تمثيل حساب مصرفي أو بنكي بالجافا

اذهب الى الأسفل

تمارين بلغة الجافا ...تمثيل حساب مصرفي أو بنكي بالجافا Empty تمارين بلغة الجافا ...تمثيل حساب مصرفي أو بنكي بالجافا

مُساهمة من طرف أحمد مناع السبت أبريل 25, 2020 3:39 pm

اليكم الاسئلة و الحل 

تمارين بلغة الجافا ...تمثيل حساب مصرفي أو بنكي بالجافا 9410


الحل على النحو التالى :

Bank_Account.java

الكود:

package egybanc.Bank;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;


public class Bank_Account {

 
static final int current_account=1,Fixed_account=2;

private double Tel_NO;
private int  Branch_NO;
private String Customer_No,Customer_Name,Email,Bank_name,Branch_addr,Recipient_addr;
private String occupation ;
private double amount,amount_transfer,Amount_opened,value_Rate;
private final int account_type;
private int Transfer_type;
private Date  date_opened ;    
private Date  Transfer_date ;
    
  

    public Bank_Account(int account_type,int Amount_opened ){
    
      
        this.account_type=account_type;
         if (Amount_opened < 250) {
         System.out.println("An amount of $ 250 is required to open the account.");
        }else
        this.amount=Amount_opened;
    }
    
    
      // طريقة لحساب عدد احرف اسم العميل
    public int Namelength(String name) {
          int count = 0;  
         for(int i = 0; i < name.length(); i++) {    
            if(name.charAt(i) != ' ')    
                count++;    
        }    
          return count;
     }
 
    // طريقتين لتعين و ارجاع أسم مالك الحساب
    public void setCustomerName(String Name) {
        
        if ( Namelength(Name) > 10 && Namelength(Name) < 30){
          System.out.println("Customer name must not exceed 30 or less than 10 characters.");    
        }else
          
        
        this.Customer_Name= Name;
     }
    public String getCustomerName() {
        return this.Customer_Name ;
     }
    
    //طريقين لتعين و ارجاع رقم الحساب
    public void setCustomerNo(String No) {
        this.Customer_No= No;
     }
    public String getCustomerNo() {
        return this.Customer_No ;
     }
  
     // طريقتين لتعين و ارجاع رقم العاتف لمالك الحساب
    public void setTell_NO(int NO) {
        this.Tel_NO= NO;
     }
    public double  getTell_NO() {
        return this.Tel_NO ;
     }
    
     //طريقين لتعين و ارجاع عنوان البريد الالكتروني
    public void setEmail(String mail_adrr) {
        this.Email= mail_adrr;
     }
    public String getEmail() {
        return this.Email ;
     }
    
      // طريقتين لتعين و ارجاع مهنة لمالك الحساب
    public void setOccupation(String s) {
        this.occupation= s;
     }
    public String getOccupation() {
        return this.occupation ;
     }
    
    // طريقة لارجاع القيمة الافتتاحية
    public double  getAmount_opened() {
        return this.Amount_opened ;
     }
    
    //طريقة لارجاع نوع الحساب
    
    public String getAccount_type() {
        
        if (this.account_type==1){
            return "current_account" ;
        }else if (this.account_type==2){
            return "Fixed_account";
        }
    return null;
        
      
     }
    
    
    // طريقة لارجاع تاريخ انشاء الحساب
    public String getDate_created() {
     DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        
    return dateFormat.format(this.date_opened =new Date());
            
     }
    
     // طريقة لارجاع تاريخ الحوالة
    public String getTransfer_date() {
     DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        
    return dateFormat.format(this.Transfer_date =new Date());
            
     }
    
    // طريقتين لتعين و ارجاع رقم الفرع
    public void setBranchNO(int No) {
        this.Branch_NO= No;
     }
    public int getBranchNO() {
        return this.Branch_NO ;
     }
    
      //طريقين لتعين و ارجاع عنوان الفرع
    public void setBranch_addr(String Addr) {
        this.Branch_addr= Addr;
     }
    public String getBranch_addr() {
        return this.Branch_addr ;
     }
    
    
     // طريقتين لتعين و ارجاع مبلغ الحوالة البنكية
    public void setAmount_transfer(double value) {
        this.amount_transfer= value;
     }
    public double  getAmount_transfer() {
        return this.amount_transfer ;
     }
    
     // طريقتين لتعين و ارجاع  عنوان مستلم الحوالة
    public void setRecipient_addr(String addr) {
        this.Recipient_addr= addr;
     }
    public String getRecipient_addr() {
        return this.Recipient_addr ;
     }
    
    // طريقة لارجاع اسم البنك
    public String getBank_Name() {
        return this.Bank_name ;
     }
    
     // طريقتين لتعين و ارجاع   نوع الحوالة
    public void setTransfer_type(int type) {
        this.Transfer_type= type;
     }
    public int  getTransfer_type() {
        return this.Transfer_type ;
     }
    
    
    // دالة ايداع مبلغ نقدي
    public void deposit(double value)
   {
      amount = amount + value;
   }

    
    // دالة سحب مبلغ نقدي
    public void withdraw(double value){
        
        if(value > 1000){
         System.out.println("It is not possible to withdraw more than 1000 $ at a time");
        }else
        
       amount = amount - value;
      
     }
    
     // دالة ارجاع قيمة الرصيد
    public double getBalance() {
        return this.amount ;
    }
    
     // دالة ارجاع قيمة الحوالة
    public double getTransfer_Value() {
        return this.amount_transfer ;
    }
    
     // طريقة لحساب الفائدة السنوية على الرصيد
    public double CalInterst_Rate() {
      
        if (account_type==current_account){
          this.value_Rate= this.amount*.10;
          
        }
    return this.value_Rate;
        
     }
    
    // دالة لتحويل حوالة بنكية مع معالجة الرصيد
    public void TransferTo( String Bank_name,int Branch_NO ,String Branch_addr,String Recipient_addr,int Transfer_type, double Amount_Transfer)
    {
        this.Bank_name=Bank_name;
        this.Branch_NO=Branch_NO;
        this.Branch_addr=Branch_addr;
        this.setRecipient_addr(Recipient_addr);
        this.setTransfer_type(Transfer_type);
        this.setAmount_transfer(Amount_Transfer);
        
        
        this.amount= this.amount- Amount_Transfer;
    }
}


Employee_Account.java

الكود:

package egybanc.Bank;


public class Employee_Account extends Bank_Account {

    private String employer,address;

    public Employee_Account(int account_type, int Amount_opened) {
        super(account_type, Amount_opened);
        
    }

    
  
    
      // طريقتين لتعين و ارجاع جهة العمل
    public void setEmployer(String Name) {
        this.employer= Name;
     }
    public String getEmployer() {
        return this.employer ;
     }
    
      // طريقتين لتعين و ارجاع عنوان  جهة العمل
    public void setJobAddress(String Addr) {
        this.address= Addr;
     }
    public String getJobAddress() {
        return this.address ;
     }
    
    public void getData(){
    
        System.out.println("\t\t\t\t ****** Employee Account Details ******\n ");
        
        System.out.println("\t ****** Basic data details ******\n ");
        
        System.out.println(" Holder Name      : "+ this.getCustomerName());
        System.out.println(" Telephone number : "+ this.getTell_NO());
        System.out.println(" Email address    : "+ this.getEmail());
        System.out.println(" Job title        : "+  this.getOccupation());
        System.out.println(" Place of work    : "+  this.getEmployer());
        System.out.println(" work address     : "+  this.getJobAddress());
      
        
        System.out.println();
        
        System.out.println("\t ****** Account data details ******\n ");
        
       //The value of withdrawal
        System.out.println(" Account No       : "+ this.getCustomerNo());
        System.out.println(" Date Opened      : "+ this.getDate_created());
        System.out.println(" Account Type     : "+ this.getAccount_type());
        System.out.println(" Initial Balance  : "+ this.getAmount_opened());
        System.out.println(" Current Balance  : "+ this.getBalance());
        System.out.println(" value of interest : "+ this.CalInterst_Rate());
        
        System.out.println();
        
        System.out.println("\t ****** Bank transfer details ******\n ");
        System.out.println(" Transfer date       : "+ this.getTransfer_date());
        System.out.println(" The Bank Name       : "+ this.getBank_Name());
        System.out.println(" Branch Number       : "+ this.getBranchNO());
        System.out.println(" Branch Address      : "+ this.getBranch_addr());
        System.out.println(" Amount of Transfer  : "+ this.getTransfer_Value());
        
        
        
        
        System.out.println("\t\t\t\t ****** Savings Account Details ******\n ");

        
        
    }
}


StudentAccount.java

الكود:

package egybanc.Bank;

public class StudentAccount extends Bank_Account{

     private String School_name,address;

    public StudentAccount(int account_type, int Amount_opened) {
        super(account_type, Amount_opened);
    }
    
  
    
      // طريقتين لتعين و ارجاع جهة الدراسة
    public void setEducational_Facility(String Name) {
        this.School_name= Name;
     }
    public String getEducational_Facility() {
        return this.School_name ;
     }
    
      // طريقتين لتعين و ارجاع عنوان الجامعة أو المدرسة
    public void setJobAddress(String Addr) {
        this.address= Addr;
     }
    public String getJobAddress() {
        return this.address ;
     }
    

     public void getData(){
    
        System.out.println("\t\t\t\t ****** Student Account Details ******\n ");
        
        System.out.println("\t ****** Basic data details ******\n ");
        
        System.out.println(" Holder Name          : "+ this.getCustomerName());
        System.out.println(" Telephone number     : "+ this.getTell_NO());
        System.out.println(" Email address        : "+ this.getEmail());
        System.out.println(" Job title            : "+  this.getOccupation());
        System.out.println(" Educational facility : "+  this.getEducational_Facility());
        System.out.println(" Educational address  : "+  this.getJobAddress());
        
        System.out.println();
        
        System.out.println("\t ****** Account data details ******\n ");
        
       //The value of withdrawal
        System.out.println(" Account No       : "+ this.getCustomerNo());
        System.out.println(" Date Opened      : "+ this.getDate_created());
        System.out.println(" Account Type     : "+ this.getAccount_type());
        System.out.println(" Initial Balance  : "+ this.getAmount_opened());
        System.out.println(" Current Balance  : "+ this.getBalance());
        System.out.println(" value of interest : "+ this.CalInterst_Rate());
        
        System.out.println();
        
        System.out.println("\t ****** Bank transfer details ******\n ");
        System.out.println(" Transfer date       : "+ this.getTransfer_date());
        System.out.println(" The Bank Name       : "+ this.getBank_Name());
        System.out.println(" Branch Number       : "+ this.getBranchNO());
        System.out.println(" Branch Address      : "+ this.getBranch_addr());
        System.out.println(" Amount of Transfer  : "+ this.getTransfer_Value());
        
        
        
        
        
        System.out.println("\t\t\t\t ****** Student Account Details ******\n ");

        
        
    }


}





Dealer_Account.java

الكود:

package egybanc.Bank;

public class Dealer_Account extends Bank_Account{
    
     private String employer,address;

    public Dealer_Account(int account_type, int Amount_opened) {
        super(account_type, Amount_opened);
    }

    
    
      // طريقتين لتعين و ارجاع جهة العمل
    public void setTrade_place(String Name) {
        this.employer= Name;
     }
    public String getTrade_place() {
        return this.employer ;
     }
    
      // طريقتين لتعين و ارجاع عنوان  جهة العمل
    public void setJobAddress(String Addr) {
        this.address= Addr;
     }
    public String getJobAddress() {
        return this.address ;
     }

    
    
    public void getData(){
    
        System.out.println("\t\t\t\t ****** Dealer Account Details ******\n ");
        
        System.out.println("\t ****** Basic data details ******\n ");
        
        System.out.println(" Holder Name      : "+ this.getCustomerName());
        System.out.println(" Telephone number : "+ this.getTell_NO());
        System.out.println(" Email address    : "+ this.getEmail());
        System.out.println(" Job title        : "+  this.getOccupation());
        System.out.println(" Place of work    : "+  this.getTrade_place());
        System.out.println(" work address     : "+  this.getJobAddress());
      
        
        System.out.println();
        
        System.out.println("\t ****** Account data details ******\n ");
        
       //The value of withdrawal
        System.out.println(" Account No       : "+ this.getCustomerNo());
        System.out.println(" Date Opened      : "+ this.getDate_created());
        System.out.println(" Account Type     : "+ this.getAccount_type());
        System.out.println(" Initial Balance  : "+ this.getAmount_opened());
        System.out.println(" Current Balance  : "+ this.getBalance());
        System.out.println(" value of interest : "+ this.CalInterst_Rate());
        
        System.out.println();
        
        System.out.println("\t ****** Bank transfer details ******\n ");
        System.out.println(" Transfer date       : "+ this.getTransfer_date());
        System.out.println(" The Bank Name       : "+ this.getBank_Name());
        System.out.println(" Branch Number       : "+ this.getBranchNO());
        System.out.println(" Branch Address      : "+ this.getBranch_addr());
        System.out.println(" Amount of Transfer  : "+ this.getTransfer_Value());
        
        
        
        
        System.out.println("\t\t\t\t ****** Dealer Account Details ******\n ");

        
        
    }

}



و التفيذ فى الدالة الرئسية على النحو التالى :

الكود:

package egybanc.Bank;

import static egybanc.Bank.Bank_Account.current_account;

public class Test {

 static final int Study_expenses=1,personal_expenses=2,Buy_materials=3,Other_expenses=4;

    public static void main(String[] args) {
        
        Employee_Account E = new Employee_Account(current_account,5000);
        E.setCustomerNo("A_125");
        E.setCustomerName("AHMED ");
        E.setTell_NO(01222222);
        E.setEmail("EXP@gmail.com");
        E.setOccupation("Financial Manager");
        E.setEmployer("Nile Plastic Company");
        E.setJobAddress("15 May Street, Downtown, Cairo");
        
        
        
        E.deposit(2500);
        
        E.withdraw(1000);
        
        E.TransferTo("Faisal Islamic Bank",8,"119, Tahrir Street, Cairo", "5 Muharram Bey Street", personal_expenses, 2000);
        
        E.getData();
    }
    
}

المخرجات

تمارين بلغة الجافا ...تمثيل حساب مصرفي أو بنكي بالجافا Untitl21

ـــــــــــــــــــ التوقيع ــــــــــــــــــــ
سبحان الله وبحمدة .....سبحان الله العظيم
أحمد مناع
أحمد مناع
.
.

تاريخ التسجيل : 15/02/2011
المساهمات : 1108
النقاط : 202034
التقيم : 144
الدولة : مصر
الجنس : ذكر

https://egy-tech.forumegypt.net

الرجوع الى أعلى الصفحة اذهب الى الأسفل

تمارين بلغة الجافا ...تمثيل حساب مصرفي أو بنكي بالجافا Empty رد: تمارين بلغة الجافا ...تمثيل حساب مصرفي أو بنكي بالجافا

مُساهمة من طرف vbcoder الأحد مايو 10, 2020 11:33 pm


تحياتى يا كبير على كل هذا الجهد
vbcoder
vbcoder
....
....

تاريخ التسجيل : 18/11/2018
المساهمات : 51
النقاط : 81
التقيم : 4
الدولة : مصر
الجنس : ذكر

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة

ََ

مواضيع ذات صلة


 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى