Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CsharpDemo2
- {
- class Account
- {
- // Instance variables
- private int acno;
- private string ahname;
- private double balance;
- //private static int minbal = 5000;
- // Constructor
- public Account(int ano, string name, double bal = 0)
- {
- acno = ano;
- ahname = name;
- balance = bal;
- }
- // Methods
- public void Deposit(double amount)
- {
- Console.WriteLine("\n\nInitialising Deposit....");
- if (amount > 0){
- balance += amount;
- Console.WriteLine("Balance updated \nAvilable Balance:"+balance);
- }
- else
- Console.WriteLine("Invalid amount!");
- }
- public void Withdraw(double amount)
- {
- Console.WriteLine("\n\n Initialising Withdraw....");
- if (amount <= balance){
- balance -= amount;
- Console.WriteLine("Amount Withdrawn:"+amount+"\nAvilable Balance in Account:"+balance);
- }
- else
- Console.WriteLine("Insufficient Balance!");
- }
- public void Print()
- {
- Console.WriteLine(acno);
- Console.WriteLine(ahname);
- Console.WriteLine(balance);
- }
- }
- class Testacc
- {
- public static void Main()
- {
- Account a = new Account(101,"abcd");
- a.Print();
- a.Deposit(42356.51);
- a.Withdraw(40000);
- a.Withdraw(2306);
- a.Deposit(0.49);
- a.Withdraw(2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement