C# Bank account using single Inheritance...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace inheritance_1
{
    class bank_account
    {
        public float account_balance=0;
        public float deposit,amount;
        public float withdraw,remaining;
     
        public void credit()
        {
            Console.WriteLine("enter the amount you want to deposit");
            deposit = float.Parse(Console.ReadLine());
            amount = account_balance + deposit;
            Console.WriteLine("your account balance is {0}:",amount);
     
       }
           
        public void debit()
        {
            if (account_balance >= withdraw)
            {
                Console.WriteLine("enter the amount you want too with draw");
                withdraw = float.Parse(Console.ReadLine());
                remaining = amount-withdraw;
                Console.WriteLine("your reamining amount is {0}", remaining);
            }
            else
            {
                Console.WriteLine("your account balance is not enough");
         
         
         
         
            }
        }
        public void getbalance() {


            Console.WriteLine("your final balance is {0}:",remaining);
     
        }


        class saving_accounts:bank_account
        {
         
            public float interest_rate;
         
            public void calculate_interest() {

                Console.WriteLine("my BANK PROVIDED YOU 5% intrest rate");
                interest_rate = (account_balance * 5) / 100;
                Console.WriteLine("YOUR Interest rate is {0}",interest_rate);
            }
     
     
     
        }
        class checking_account:bank_account {

            public float fee_charged=5;
            public float res;
            public void checking() {


                res = remaining - fee_charged;
                Console.WriteLine("your remaining balance after 5% fees transaction is : {0} ",res);

            }
         
     
     
     


           }
        static void Main(string[] args)
        {
            checking_account obj = new checking_account();
            obj.credit();
            obj.debit();
            obj.getbalance();
            saving_accounts obj2 = new saving_accounts();
            obj2.calculate_interest();
            obj.checking();
                Console.ReadKey();
        }
    }
}







No comments:

Post a Comment