pseudocode and c# only please. a. Design a class named Checking Account that hol
ID: 3818554 • Letter: P
Question
pseudocode and c# only please.
a. Design a class named Checking Account that holds a checking account number,
name of account holder, and balance. Include methods to set values for each
data field and a method that displays all the account information. Create the
class diagram and write the pseudocode that defines the class.
d. Design an application that declares an array of five Checking Account objects.
Prompt the user for data for each object, and then pass the array to a method
that determines the sum of the balances.
Explanation / Answer
Hi,
Please find the psuedocode below:-
Algorithms for class CheckingAccount
Begin algorithm CheckingAccount
Step1:-Declare variable account number,account name,balances
Step 2:- define all methods setAccnum, setAcname, setBalance which will set the values of these variables
Step 3:=define a method getInformation which will display information of these variables
Step4:-Define a method CalcBal which will take array of object as parameter obj CAarr[] and calculate sum of balances of the account and display it.
End algorithm CheckingAccount
=========================================================================
Please find the c # code for the asignment below:-
CODE:-
=============================================================================
using System;
namespace AccountApplication
{
class CheckingAccount
{
private double accnum;
private string accname;
private double balances;
public void setAccnum( double account )
{
accnum = account;
}
public void setAcname( string name )
{
accname = name;
}
public void setBalance( double balance )
{
balances = balance;
}
public void getInformation()
{
Console.WriteLine("Account number : {0}" ,accnum);
Console.WriteLine("Account Holder Name : {0}" ,accname);
Console.WriteLine("Account Balance : {0}" ,balances);
}
public void CalcBal(obj CAarr[])
{
double sum=0.00
for (int j=0;j<5;j++)
{
sum=sum+CAarr[j].balances;
}
Console.WriteLine("Total Balances is: {0}",sum);
}
}
class AccountChecking
{
static void Main(string[] args)
{
CheckingAccount[] CA = new CheckingAccount[5]; // Declare CA as object of 5 arrays
//get input from user in the loop
for (int i=0;i<5;i++)
{
Console.WriteLine("Type an Account no:");
double accno = Console.ReadLine();
Console.WriteLine("Type an Account holders name:");
string accnames = Console.ReadLine();
Console.WriteLine("Type an Account balances");
double bal = Console.ReadLine();
CA[i]=new CheckingAccount();
CA[i].accnum=accno;
CA[i].accname=accnames;
CA[i].balances=bal;
}
//calculate all balances by passing object
CalcBal(CA);
Console.ReadKey();
}
}
}
==================================================================================
please let me know in case of clarification.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.