Design a class named Account using c# programming language, Exercises of Programming Languages

(The Account class) Design a class named Account that contains: An int data field named id for the account (default 0). A double data field named balance for the account (default 0). A double data field named annualInterestRate that stores the current interest rate (default 0). A Date data field named dateCreated that stores the date when the account was created. A constructor for initializing id, balance, and annualInterestRate and dateCreated. A method named getMonthlyInterestRate() that

Typology: Exercises

2021/2022

Uploaded on 06/03/2022

jj-toraja
jj-toraja 🇵🇭

5 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
...epos\BSIT3-2\Class_Activity\Class_Activity\Program.cs 1
//Rivas, Joy B.
//BSIT 3-2
using System;
public class Account
{
int id = 0;
double balance = 0;
double annualInterestRate = 0;
DateOnly dateCreated = new DateOnly(2022, 06, 02);
public Account(int ID, double bal, double InterestRateValue)
{
balance = bal;
id = ID;
annualInterestRate = InterestRateValue;
}
public int getID()
{
return id;
}
public double getBalance()
{
return balance;
}
public double getannualInterestRate()
{
return annualInterestRate;
}
public DateOnly getdateCreated()
{
return dateCreated;
}
public double getMonthlyInterestRate()
{
double interest = annualInterestRate / 12;
return interest;
}
public void withdraw(double withdrawAmount)
{
balance = balance - withdrawAmount;
}
pf2

Partial preview of the text

Download Design a class named Account using c# programming language and more Exercises Programming Languages in PDF only on Docsity!

...epos\BSIT3-2\Class_Activity\Class_Activity\Program.cs 1 //Rivas, Joy B. //BSIT 3- 2 using System; public class Account { int id = 0; double balance = 0; double annualInterestRate = 0; DateOnly dateCreated = new DateOnly(2022, 06, 02); public Account(int ID, double bal, double InterestRateValue) { balance = bal; id = ID; annualInterestRate = InterestRateValue; } public int getID() { return id; } public double getBalance() { return balance; } public double getannualInterestRate() { return annualInterestRate; } public DateOnly getdateCreated() { return dateCreated; } public double getMonthlyInterestRate() { double interest = annualInterestRate / 12; return interest; } public void withdraw(double withdrawAmount) { balance = balance - withdrawAmount; }

...epos\BSIT3-2\Class_Activity\Class_Activity\Program.cs 2 public void deposit(double depositAmount) { balance = balance + depositAmount; } public void displayBalance() { Console.WriteLine("Account Balance: Php {0}", getBalance()); } public void displayMonthlyInterest() { Console.WriteLine("Monthly Interest: {0}%", getMonthlyInterestRate()); } public void displaydateCreated() { Console.WriteLine("Account was created on: {0}", getdateCreated()); } public static void Main(String[] args) { Account myAccount = new Account(1122, 20000, 4.5); myAccount.withdraw(2500); myAccount.deposit(3000); myAccount.displayBalance(); myAccount.displayMonthlyInterest(); myAccount.displaydateCreated(); } }