Question

In: Computer Science

Programming Language: C# Person Class Fields - password : string Properties + «C# property, setter private»...

Programming Language: C#

Person

Class

Fields

- password : string

Properties

+ «C# property, setter private» IsAuthenticated : bool

+ «C# property, setter absent» SIN : string

+ «C# property, setter absent» Name : string

Methods

+ «Constructor» Person(name : string, sin : string)

+ Login(password : string) : void

+ Logout() : void

+ ToString() : string

Transaction

Class

Properties

+ «C# property, setter absent » AccountNumber : string

+ «C# property, setter absent» Amount : double

+ «C# property, setter absent» Originator : Person

+ «C# property, setter absent» Time : DateTime

Methods

+ «Constructor» Transaction(accountNumber : string, amount : double, endBalance : double, person : Person, time : DateTime)

+ ToString() : string

ITransaction

Interface

Methods

   Withdraw(amount : double, person : Person) : void

   Deposit(amount : double, person : Person) : void

Account

Abstract Class

Fields

# «readonly» users : List<Person>

# «readonly» transactions : List<Transaction>

$- LAST_NUMBER = 100_000: int

Properties

+ «C# property, setter absent» Number: string

+ «C# property, protected setter» Balance: double

+ «C# property, protected setter» LowestBalance : double

Methods

+ «Constructor» Account(type : string, balance : double)

+ Deposit(balance : double, person : Person) : void

+ AddUser(person : Person) : string

+ IsUser(name : string) : bool

+ «C# abstract method» PrepareMonthlyStatement() : void

+ ToString() : string

CheckingAccount

Class

→ Account, ITransaction

Fields

$- COST_PER_TRANSACTION = 0.05 : double

$- INTEREST_RATE = 0.005 : double

- hasOverdraft: bool

Methods

+ «Constructor» CheckingAccount(balance = 0 : double, hasOverdraft = false: bool)

+ Deposit(amount : double, person : Person) : void

+ Withdraw(amount : double, person : Person) : void

+ PrepareMonthlyReport(amount : double, person : Person) : void

SavingAccount

Class

→ Account, ITransaction

Fields

$- COST_PER_TRANSACTION : double

$- INTEREST_RATE : double

Methods

+ «Constructor» SavingAccount(balance = 0 : double)

+ Deposit(amount : double, person : Person) : void

+ Withdraw(amount : double, person : Person) : void

+ PrepareMonthlyReport(amount : double, person : Person) : void

Solutions

Expert Solution

Working code implemented in C# and appropriate comments provided for better understanding:

Here I am attaching code for these files:

  • main.cs
  • Bank.cs
  • Person.cs
  • Account.cs
  • SavingAccount.cs
  • CheckingAccount.cs
  • Transaction.cs
  • VisaAccount.cs
  • AccountException.cs

Source code for main.cs:

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

namespace Assignment04_BankApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("---- START RUNING CODE FROM PROGRAM.CS -----");

//testing the visa account
Console.WriteLine("\nAll acounts:");
Bank.PrintAccounts();
Console.WriteLine("----- PASSED PRINT ACCOUNTS -----");

Console.WriteLine("\nAll Users:");
Console.WriteLine();
Bank.PrintPersons();
Console.WriteLine();
Console.WriteLine("----- PASSED PRINT PERSONS -----");

Person p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10;
p0 = Bank.GetPerson("Narendra");
p1 = Bank.GetPerson("Ilia");
p2 = Bank.GetPerson("Tom");
p3 = Bank.GetPerson("Syed");
p4 = Bank.GetPerson("Arben");
p5 = Bank.GetPerson("Patrick");
p6 = Bank.GetPerson("Yin");
p7 = Bank.GetPerson("Hao");
p8 = Bank.GetPerson("Jake");
p9 = Bank.GetPerson("Joanne");
p10 = Bank.GetPerson("Nicoletta");
Console.WriteLine();
Console.WriteLine("----- PASSED PERSON REQUEST -----");

p0.Login("123");
p1.Login("234");
p2.Login("345");
p3.Login("456");
p4.Login("567");
p5.Login("678");
p6.Login("789");
p7.Login("890");
p10.Login("234");
p8.Login("901");
Console.WriteLine();
Console.WriteLine("----- PASSED LOGINS -----");

//a visa account
VisaAccount a = Bank.GetAccount("VS-100000") as VisaAccount;
a.DoPayment(1500, p0);
a.DoPurchase(200, p1);
a.DoPurchase(25, p2);
a.DoPurchase(15, p0);
a.DoPurchase(39, p1);
a.DoPayment(400, p0);
Console.WriteLine(a);
Console.WriteLine();
Console.WriteLine("----- PASSED TRANSACTIONS FOR VS-100000 -----");

VisaAccount aa = (VisaAccount)Bank.GetAccount("VS-100001");
aa.DoPayment(500, p0);
aa.DoPurchase(25, p3);
aa.DoPurchase(20, p4);
aa.DoPurchase(15, p5);
Console.WriteLine(aa);
Console.WriteLine();
Console.WriteLine("----- PASSED TRANSACTIONS FOR VS-100001 -----");


//a saving account
ITransaction b = Bank.GetAccount("SV-100002") as ITransaction;
b.Withdraw(300, p6);
b.Withdraw(32.90, p6);
b.Withdraw(50, p7);
b.Withdraw(111.11, p8);
Console.WriteLine(b);
Console.WriteLine();
Console.WriteLine("----- PASSED TRANSACTIONS FOR SV-100002 -----");

b = (SavingAccount)Bank.GetAccount("SV-100003");
b.Deposit(300, p3); //ok even though p3 is not a holder
b.Deposit(32.90, p2);
b.Deposit(50, p5);
b.Withdraw(111.11, p10);
Console.WriteLine(b);
Console.WriteLine();
Console.WriteLine("----- PASSED TRANSACTIONS FOR SV-100003 -----");


//a checking account
ITransaction c = Bank.GetAccount("CK-100004") as ITransaction;
c.Deposit(33.33, p7);
c.Deposit(40.44, p7);
c.Withdraw(150, p2);
c.Withdraw(200, p4);
c.Withdraw(645, p6);
c.Withdraw(350, p6);
Console.WriteLine(c);
Console.WriteLine();
Console.WriteLine("----- PASSED TRANSACTIONS FOR SV-100004 -----");

c = Bank.GetAccount("CK-100005") as ITransaction;
c.Deposit(33.33, p8);
c.Deposit(40.44, p7);
c.Withdraw(450, p10);
c.Withdraw(500, p8);
c.Withdraw(645, p10);
c.Withdraw(850, p10);
Console.WriteLine(c);
Console.WriteLine();
Console.WriteLine("----- PASSED TRANSACTIONS FOR SV-100005 -----");

a = Bank.GetAccount("VS-100006") as VisaAccount;
a.DoPayment(700, p0);
a.DoPurchase(20, p3);
a.DoPurchase(10, p1);
a.DoPurchase(15, p1);
Console.WriteLine(a);
Console.WriteLine();
Console.WriteLine("----- PASSED TRANSACTIONS FOR SV-100006 -----");

b = (ITransaction)Bank.GetAccount("SV-100007");
b.Deposit(300, p3); //ok even though p3 is not a holder b.Deposit(32.90, p2);
b.Deposit(50, p5);
b.Withdraw(111.11, p7);
Console.WriteLine(b);
Console.WriteLine();
Console.WriteLine("----- PASSED TRANSACTIONS FOR SV-100007 -----");


//The following will cause exception
Console.WriteLine("\n\nExceptions:");
try
{
p8.Login("911"); //incorrect password
}
catch (AccountException e)
{
Console.WriteLine(e.Message);
}

try
{
p3.Logout();
a.DoPurchase(12.5, p3); //exception user is not logged in
}
catch (AccountException e)
{
Console.WriteLine(e.Message);
}

try
{
a.DoPurchase(12.5, p0); //user is not associated with this account
}
catch (AccountException e)
{
Console.WriteLine(e.Message);
}

try
{
a.DoPurchase(5825, p4); //credit limit exceeded
}
catch (AccountException e)
{
Console.WriteLine(e.Message);
}

try
{
c.Withdraw(1500, p6); //no overdraft
}
catch (AccountException e)
{
Console.WriteLine(e.Message);
}

try
{
Bank.GetAccount("CK-100018"); //account does not exist
}
catch (AccountException e)
{
Console.WriteLine(e.Message);
}

try
{
Bank.GetPerson("Trudeau"); //user does not exist
}
catch (AccountException e)
{
Console.WriteLine(e.Message);
}


foreach (Account account in Bank.ACCOUNTS)
{
Console.WriteLine("\nBefore PrepareMonthlyReport()");
Console.WriteLine(account);
Console.WriteLine("\nAfter PrepareMonthlyReport()");
account.PrepareMonthlyReport(); //all transactions are cleared, balance changes
Console.WriteLine(account);
}
}
}
}


Source code for Bank.cs:

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

namespace Assignment04_BankApp
{
static class Bank
{
// fields properties
public static readonly List<Account> ACCOUNTS;
public static readonly List<Person> USERS;

// constructor
static Bank()
{
//initialize the USERS collection
USERS = new List<Person>()
{
new Person("Narendra", "1234-5678"), //0
new Person("Ilia", "2345-6789"), //1
new Person("Tom", "3456-7890"), //2
new Person("Syed", "4567-8901"), //3
new Person("Arben", "5678-9012"), //4
new Person("Patrick", "6789-0123"), //5
new Person("Yin", "7890-1234"), //6
new Person("Hao", "8901-2345"), //7
new Person("Jake", "9012-3456"), //8
new Person("Joanne", "1224-5678"), //9
new Person("Nicoletta", "2344-6789"), //10
};

//initialize the ACCOUNTS collection
ACCOUNTS = new List<Account>()
{
new VisaAccount(), //VS-100000
new VisaAccount(150, -500), //VS-100001
new SavingAccount(5000), //SV-100002
new SavingAccount(), //SV-100003
new CheckingAccount(2000), //CK-100004
new CheckingAccount(1500, true), //CK-100005
new VisaAccount(50, -550), //VS-100006
new SavingAccount(1000), //SV-100007
};

//associate users with accounts
ACCOUNTS[0].AddUser(USERS[0]);
ACCOUNTS[0].AddUser(USERS[1]);
ACCOUNTS[0].AddUser(USERS[2]);

ACCOUNTS[1].AddUser(USERS[3]);
ACCOUNTS[1].AddUser(USERS[4]);
ACCOUNTS[1].AddUser(USERS[5]);

ACCOUNTS[2].AddUser(USERS[6]);
ACCOUNTS[2].AddUser(USERS[7]);
ACCOUNTS[2].AddUser(USERS[8]);

ACCOUNTS[3].AddUser(USERS[9]);
ACCOUNTS[3].AddUser(USERS[10]);

ACCOUNTS[4].AddUser(USERS[2]);
ACCOUNTS[4].AddUser(USERS[4]);
ACCOUNTS[4].AddUser(USERS[6]);

ACCOUNTS[5].AddUser(USERS[8]);
ACCOUNTS[5].AddUser(USERS[10]);

ACCOUNTS[6].AddUser(USERS[1]);
ACCOUNTS[6].AddUser(USERS[3]);

ACCOUNTS[7].AddUser(USERS[5]);
ACCOUNTS[7].AddUser(USERS[7]);
}

// methods - acitons
public static void PrintAccounts()
{
foreach (Account account in ACCOUNTS)
{
Console.WriteLine(account);
}
}

public static void PrintPersons()
{
foreach (Person person in USERS)
{
Console.WriteLine(person);
}
}

public static Person GetPerson(string name)
{
foreach (Person person in USERS)
{
if (person.Name == name)
{
Console.WriteLine(person);
return person;
}
}
throw new AccountException(ExceptionEnum.USER_DOES_NOT_EXIST);
}

public static Account GetAccount(string number)
{
foreach (Account account in ACCOUNTS)
{
if (account.Number == number)
{
return account;
}
}
throw new AccountException(ExceptionEnum.ACCOUNT_DOES_NOT_EXIST);
}
}
}

Source code for Person.cs:

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

namespace Assignment04_BankApp
{
class Person
{
// fields and properties for person object
private string password;
public string SIN { get; }
public string Name { get; }
public bool IsAuthenticated { get; private set; }

// constructor for person object
public Person(string name, string SIN)
{
Name = name;
this.SIN = SIN;
password = SIN.Substring(0,3);
}

// methods - actions of the person class
public void Login(string password)
{
try
{
if (password != this.password)
{
IsAuthenticated = false;
throw new AccountException(ExceptionEnum.PASSWORD_INCORRECT);
}
else
{
IsAuthenticated = true;
Console.WriteLine($"{Name,-15}\thas logged IN.");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}

}

public void Logout()
{
IsAuthenticated = false;
Console.WriteLine($"{Name,-15}\thas logged OUT.");
}

public override string ToString()
{
return $"{Name}";
}
}
}

Source code for ​​​​​​​Account.cs:

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

namespace Assignment04_BankApp
{
abstract class Account
{
// fields and properties for the account class
public readonly List<Person> users = new List<Person>();
public readonly List<Transaction> transactions = new List<Transaction>();
private static int LAST_NUMBER = 100_000;
public double Balance { get; protected set; }
public double LowestBalance { get; protected set; }
public string Number { get; }

// constructor of the account class
public Account(string type, double balance)
{
Number = $"{type}{LAST_NUMBER}";
LAST_NUMBER++;
Balance = balance;
LowestBalance = balance;
}

// methos - actions of the account class
public void Deposit(double amount, Person person)
{
Balance += amount;
if (Balance < LowestBalance)
{
LowestBalance = Balance;
}
transactions.Add(new Transaction(Number, amount, person, DateTime.Now));
}

public void AddUser(Person person)
{
users.Add(new Person(person.Name, person.SIN));
}

public bool IsUser(string name)
{
foreach (Person person in users)
{
if (person.Name == name)
{
return true;
}
}
return false;
}

public abstract void PrepareMonthlyReport();

public override string ToString()
{
return $"\n--- ACCOUNT INFO:\n" +
$"Account Number:\t{Number}\n" +
$"Users:\t\t{string.Join(", ", users)}\n" +
$"Balance:\t{Balance:C}\n";
}
}
}

Source code for ​​​​​​​SavingAccount.cs:

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

namespace Assignment04_BankApp
{
class SavingAccount : Account, ITransaction
{
// fields and properties of the saving account class
private double COST_PER_TRANSACTION = 0.05;
private double INTEREST_RATE = 0.015;


// constructor for the savings account class
public SavingAccount(double balance = 0) : base("SV-", balance)
{
}


// methods - acitons of the sabings account class
public new void Deposit(double amount, Person person)
{
base.Deposit(amount, person);
}

public void Withdraw(double amount, Person person)
{
// throwing exceptions as rules specifies
try
{
if (users.Contains<Person>(person) == true)
{
throw new AccountException(ExceptionEnum.NAME_NOT_ASSOCIATED_WITH_ACCOUNT); // exceptions are brought from exceptions class
}
else if (person.IsAuthenticated == false)
{
throw new AccountException(ExceptionEnum.USER_NOT_LOGGED_IN);
}
else if (amount > Balance)
{
throw new AccountException(ExceptionEnum.NO_OVERDRAFT);
}
else
{
base.Deposit(amount * -1, person); // -1 to withdraw the amount of the account
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

public override void PrepareMonthlyReport()
{
double serviceCharge, interests;
serviceCharge = COST_PER_TRANSACTION * transactions.Count;
interests = INTEREST_RATE * LowestBalance / 12;
Balance = Balance + interests - serviceCharge;
transactions.Clear();
}
}
}

Source code for ​​​​​​​CheckingAccount.cs:

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

namespace Assignment04_BankApp
{
class CheckingAccount : Account, ITransaction
{
// fields and properties of the checking account class
private double COST_PER_TRANSACTION = 0.05;
private double INTEREST_RATE = 0.005;
private bool hasOverDraft;

// constructor of the checking account class
public CheckingAccount(double balance = 0, bool hasOverDraft = false) : base("CK-", balance) // takes the arguments from the parent class 'account'
{
this.hasOverDraft = hasOverDraft;
}

// mthods - actions of the checking account class
public new void Deposit(double amount, Person person)
{
base.Deposit(amount, person); // calls the deposit method from the parent class
}

public void Withdraw(double amount, Person person)
{
// throwing exceptions as rules specifies
try
{
if (users.Contains<Person>(person) == true)
{
throw new AccountException(ExceptionEnum.NAME_NOT_ASSOCIATED_WITH_ACCOUNT); // exceptions are brought from exceptions class
}
else if (person.IsAuthenticated == false)
{
throw new AccountException(ExceptionEnum.USER_NOT_LOGGED_IN);
}
else if (amount > Balance || hasOverDraft == false)
{
throw new AccountException(ExceptionEnum.NO_OVERDRAFT);
}
else
{
base.Deposit(amount * -1, person); // -1 to withdraw the amount of the account
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

public override void PrepareMonthlyReport()
{
double serviceCharge, interests;
serviceCharge = COST_PER_TRANSACTION * transactions.Count;
interests = INTEREST_RATE * LowestBalance / 12;
Balance = Balance + interests - serviceCharge;
transactions.Clear();
}

}
}

Source code for ​​​​​​​Transaction.cs:

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

namespace Assignment04_BankApp
{
// interface for the transaction class
interface ITransaction
{
void Withdraw(double amount, Person person);
void Deposit(double amount, Person person);
}

class Transaction
{
// flieds and properties of the class transactions
public string AccountNumber { get; }
public double Amount { get; }
public Person Originator { get; }
public DateTime Time { get; }

// constructor for the transaction class
public Transaction(string accountNumber, double amount, Person person, DateTime time)
{
AccountNumber = accountNumber;
Amount = amount;
Originator = person;
Time = time;
}

// methods - actions for the transaction class
public override string ToString()
{
return $"\n--- TRANSACTION INFO:\n" +
$"Date:\t\t\t{Time.ToShortTimeString()}\n" +
$"Name:\t\t\t{Originator}\n" +
$"Account Number:\t\t{AccountNumber}\n" +
$"Transaction:\t\t{Amount:C}\n";
}

}
}

Source code for ​​​​​​​VisaAccount.cs:

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

namespace Assignment04_BankApp
{
class VisaAccount : Account, ITransaction
{
// fields and properties of visa account class
private double creditLimit;
private double INTEREST_RATE = 0.1995;

// constructor for visa account class
public VisaAccount(double balance = 0, double creditLimit = 1200) : base("VS-", balance)
{
this.creditLimit = creditLimit;
}

// methods - acitons of the sabings account class
public void DoPayment(double amount, Person person)
{
base.Deposit(amount, person);
}

public void DoPurchase(double amount, Person person)
{
// throwing exceptions as rules specifies
try
{
// for (int i = 0; i < users.Count; i++)
//{
if (users.Contains<Person>(person) == true)
{
throw new AccountException(ExceptionEnum.NAME_NOT_ASSOCIATED_WITH_ACCOUNT); // exceptions are brought from exceptions class
}
else if (person.IsAuthenticated == false)
{
throw new AccountException(ExceptionEnum.USER_NOT_LOGGED_IN);
}
else if (amount > creditLimit)
{
throw new AccountException(ExceptionEnum.CREDIT_LIMIT_HAS_BEEN_EXCEEDED);
}
else
{
base.Deposit(-amount, person); // -1 to withdraw the amount of the account
}
//}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

void ITransaction.Deposit(double amount, Person person)
{
base.Deposit(amount, person);
}

void ITransaction.Withdraw(double amount, Person person)
{
// throwing exceptions as rules specifies
if (users.Contains<Person>(person) == false)
{
throw new AccountException(ExceptionEnum.NAME_NOT_ASSOCIATED_WITH_ACCOUNT); // exceptions are brought from exceptions class
}
else if (person.IsAuthenticated == false)
{
throw new AccountException(ExceptionEnum.USER_NOT_LOGGED_IN);
}
else if (amount > Balance)
{
throw new AccountException(ExceptionEnum.CREDIT_LIMIT_HAS_BEEN_EXCEEDED);
}
else
{
base.Deposit(-amount, person); // -1 to withdraw the amount of the account
}
}

public override void PrepareMonthlyReport()
{
double interests;
interests = INTEREST_RATE * LowestBalance / 12;
Balance = Balance - interests;
transactions.Clear();
}
}
}

Source code for ​​​​​​​AccountException.cs:

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

namespace Assignment04_BankApp
{
public enum ExceptionEnum
{
ACCOUNT_DOES_NOT_EXIST,
CREDIT_LIMIT_HAS_BEEN_EXCEEDED,
NAME_NOT_ASSOCIATED_WITH_ACCOUNT,
NO_OVERDRAFT,
PASSWORD_INCORRECT,
USER_DOES_NOT_EXIST,
USER_NOT_LOGGED_IN
}
class AccountException : Exception
{
public AccountException(ExceptionEnum reason) : base(reason.ToString())
{
}
}
}

Sample Output Screenshots:

Hope it helps, if you like the answer give it a thumbs up. Thank you.


Related Solutions

C# Programming (Class Registration class) Add a Schedule property to the Person class. Add a new...
C# Programming (Class Registration class) Add a Schedule property to the Person class. Add a new behavior as well: add(Section s) this behavior will add a section to the Person’s schedule. The Person’s display() function will also need to be modified to display() the Person’s Schedule. Schedule class has Properties: An array of Sections and a Count. Constructors: only a default constructor is needed. Behaviors: add() and display(). This is my schedule class class Schedule     {         private int...
Suppose we have a Java class called Person.java public class Person { private String name; private...
Suppose we have a Java class called Person.java public class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName(){return name;} public int getAge(){return age;} } (a) In the following main method which lines contain reflection calls? import java.lang.reflect.Field; public class TestPerson { public static void main(String args[]) throws Exception { Person person = new Person("Peter", 20); Field field = person.getClass().getDeclaredField("name"); field.setAccessible(true); field.set(person, "Paul"); } }...
Programming Exercise Implement the following class design: class Tune { private:    string title; public:   ...
Programming Exercise Implement the following class design: class Tune { private:    string title; public:    Tune();    Tune( const string &n );      const string & get_title() const; }; class Music_collection { private: int number; // the number of tunes actually in the collection int max; // the number of tunes the collection will ever be able to hold Tune *collection; // a dynamic array of Tunes: "Music_collection has-many Tunes" public: // default value of max is a conservative...
C Programming Language Title : Making wave In Physics, Mathematics, and related fields, a wave is...
C Programming Language Title : Making wave In Physics, Mathematics, and related fields, a wave is a disturbance of one of more fields such that the field values oscillate repeatedly about a stable equilibrium value. Waves are usually represented using mathematical functions of the form F (x, t), where x = position and t = time. Your task is to write a program that will visualize a given wave for exactly N seconds. You do not need to worry about...
THIS IS JAVA PROGRAMMING Design a class named Account (that contains 1. A private String data...
THIS IS JAVA PROGRAMMING Design a class named Account (that contains 1. A private String data field named id for the account (default 0). 2. A private double data field named balance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A no-arg constructor that creates a default account. 6....
c++ programming 1.1 Class definition Define a class bankAccount to implement the basic properties of a...
c++ programming 1.1 Class definition Define a class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data:  Account holder’s name (string)  Account number (int)  Account type (string, check/savings/business)  Balance (double)  Interest rate (double) – store interest rate as a decimal number.  Add appropriate member functions to manipulate an object. Use a static member in the class to automatically assign account numbers. 1.2 Implement...
In Java, Here is a basic Name class. class Name { private String first; private String...
In Java, Here is a basic Name class. class Name { private String first; private String last; public Name(String first, String last) { this.first = first; this.last = last; } public boolean equals(Name other) { return this.first.equals(other.first) && this.last.equals(other.last); } } Assume we have a program (in another file) that uses this class. As part of the program, we need to write a method with the following header: public static boolean exists(Name[] names, int numNames, Name name) The goal of...
in C programming language char character [100] = "hello"; a string array variable It is given....
in C programming language char character [100] = "hello"; a string array variable It is given. By writing a function called TranslateString, By accessing the pointer address of this given string, returning the string's address (pointer address) by reversing the string Write the function and use it on the main function. Function void will not be written as. Return value pointer address it will be. Sweat operation on the same variable (character) It will be made. Declaration of the function...
Class object in C++ programming language description about lesson base class and derived class example.
Class object in C++ programming language description about lesson base class and derived class example.
The Person Class Uses encapsulation Attributes private String name private Address address Constructors one constructor with...
The Person Class Uses encapsulation Attributes private String name private Address address Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: name - "John Doe" address - use the default constructor of Address one constructor with all (two) parameters one input parameter for each attribute Methods public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT