0% found this document useful (0 votes)
9 views7 pages

CS411 Visual Programming Assignment 1

The document is an assignment for a Visual Programming course, detailing a C# implementation of a banking system with classes for accounts, including Savings and Current accounts. It includes methods for depositing, withdrawing, and calculating interest, along with a main program demonstrating account operations. The assignment is due on November 3, 2025, and is worth 20 marks.

Uploaded by

daniel.hshaulers
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

CS411 Visual Programming Assignment 1

The document is an assignment for a Visual Programming course, detailing a C# implementation of a banking system with classes for accounts, including Savings and Current accounts. It includes methods for depositing, withdrawing, and calculating interest, along with a main program demonstrating account operations. The assignment is due on November 3, 2025, and is worth 20 marks.

Uploaded by

daniel.hshaulers
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CS411 – Visual Programming

Assignment No. 1 (Graded) Fall 2025

Muhammad Hassan Jahangir


BC230413864

Due Date: 03-Nov-2025


Total Marks: 20

Solution Code:

using System;

namespace BankAccountSystem

// Base Class for Accounts

class Accounts

protected string accountTitle;

protected string accountNumber;

protected double balance;

// Properties for account details

public string AccountTitle

get => accountTitle;

set => accountTitle = value;

public string AccountNumber

get => accountNumber;


set => accountNumber = value;

public double Balance

get => balance;

set => balance = value;

// Default constructor

public Accounts() { }

// Deposit method

public virtual void Deposit(double amount)

if (amount > 0)

balance += amount;

[Link]($"Deposited: {amount}. New balance:


{balance}");

else

[Link]("Deposit amount must be positive.");

// Virtual Withdraw method (to be overridden)

public virtual void Withdraw(double amount)


{

[Link]("Base withdraw not implemented.");

// Display account details

public void Ac_detail()

[Link]($"Account Title: {accountTitle}");

[Link]($"Account Number: {accountNumber}");

[Link]($"Balance: {balance}");

// Derived Class: Saving (inherits from Accounts)

class Saving : Accounts

private double interestRate;

// Property for interest rate

public double InterestRate

get => interestRate;

set => interestRate = value;

// Default constructor with initial interest rate

public Saving()

interestRate = 0.06; // 6% interest rate


}

// Calculate and add profit

public void Profit()

double profit = balance * interestRate;

balance += profit;

[Link]($"Profit added: {profit}. New balance:


{balance}");

// Overridden Withdraw with minimum balance check

public override void Withdraw(double amount)

const double MIN_BALANCE = 5000;

if (amount > 0 && (balance - amount) >= MIN_BALANCE)

balance -= amount;

[Link]($"Withdrawn: {amount}. New balance:


{balance}");

else

[Link]("Withdrawal denied: Insufficient balance or


below minimum limit.");

// Derived Class: Current (inherits from Accounts)


class Current : Accounts

// Default constructor

public Current() { }

// Overridden Withdraw with minimum balance check

public override void Withdraw(double amount)

const double MIN_BALANCE = 10000;

if (amount > 0 && (balance - amount) >= MIN_BALANCE)

balance -= amount;

[Link]($"Withdrawn: {amount}. New balance:


{balance}");

else

[Link]("Withdrawal denied: Insufficient balance or


below minimum limit.");

// Main Program Class

class Program

static void Main()

// Create Saving account object

Saving savingAccount = new Saving


{

AccountTitle = "Muhammad Hassan Jahangir",

AccountNumber = "SAV12345",

Balance = 60000

};

// Create Current account object

Current currentAccount = new Current

AccountTitle = "Muhammad Hassan Jahangir",

AccountNumber = "CUR67890",

Balance = 40000

};

// Base class reference for polymorphism

Accounts accountRef;

// Process Saving Account

[Link]("--- Saving Account Operations ---");

savingAccount.Ac_detail();

accountRef = savingAccount;

[Link](20000);

[Link]();

[Link](50000); // Should succeed

[Link](20000); // Should fail (below min)

savingAccount.Ac_detail();

[Link]("\n--- Current Account Operations ---");

currentAccount.Ac_detail();
accountRef = currentAccount;

[Link](15000);

[Link](10000); // Should succeed

[Link](30000); // Should fail (below min)

currentAccount.Ac_detail();

[Link]();

Output:

The End

You might also like