Question: Help me fix this please!!!! USING C# for this program: Here is my program code for C#: Program0.cs: using System; using System.Collections.Generic; using System.Text; using

Help me fix this please!!!! USING C# for this program:

Here is my program code for C#:

Program0.cs:

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

namespace Program0 { public class Transactions { private double numberOfTransactions;

public Transactions(double numberOfTransactions) { this.numberOfTransactions = numberOfTransactions; }

public Transactions() { }

public String type { get; set; } public double amount { get; set; } }

public class Account { public double starting_balance { get; set; } //public double numberOfTransactions { get; set; }

//array of objects of transaction class Transactions[] Transactions = new Transactions[50]; private int numberOfTransactions;

//Parameterized constructor with one argument for starting balance public Account(double bal) { starting_balance = 500.00; }

public void deposit(double amt) { Transactions[0] = new Transactions(); Transactions[0].type = "Deposit"; Transactions[0].amount = amt; numberOfTransactions++; }

public double getBalance() { double balance = starting_balance; for (int i = 0; i < Transactions.Length; i++) { if (Transactions[i].type == "Deposit") balance += Transactions[i].amount; else if (Transactions[i].type == "Withdrawal") balance -= Transactions[i].amount; else balance += Transactions[i].amount; } return balance; }

public void withdraw(double amt) { Transactions[1] = new Transactions(); Transactions[1].type = "Withdrawal"; Transactions[1].amount = amt; numberOfTransactions++; }

public void addInterest() { Transactions[3] = new Transactions(numberOfTransactions); Transactions[3].type = "Adding Interest"; Transactions[3].amount = (0.05 * this.getBalance()) / 100; numberOfTransactions++; }

public void showTransactions() { Console.WriteLine("Opening Balance: ", starting_balance); for (int i = 0; i < Transactions.Length;) { Console.WriteLine("Transaction type: ", Transactions[i].type); Console.WriteLine("Transaction amount: ", Transactions[i].amount); } Console.WriteLine("Current Balance: ", this.getBalance()); } } public static class Bank_Account { static void Main(string[] args) { Account acc = new Account(1200); char input = ' '; char c = Console.ReadLine()[0]; while (true) { Console.WriteLine("MENU"); Console.WriteLine("Please choose an action to perform:"); Console.WriteLine("(D)eposit"); Console.WriteLine("(W)ithdraw"); Console.WriteLine("(C)alculateInterest"); Console.WriteLine("(S)howBalance"); Console.WriteLine("(Q)uit"); char choice = char.Parse(Console.ReadLine()); switch (choice) { case 'D': case 'd': double amount = 0; Console.WriteLine("Enter an amount to deposit"); String s1 = Console.ReadLine(); double d1 = Double.Parse(s1); acc.deposit(d1); break; case 'W': case 'w': Console.WriteLine("Enter an amount to withdraw"); String s2 = Console.ReadLine(); double d2 = Double.Parse(s2); acc.withdraw(d2); break; case 'C': case 'c': Console.WriteLine("Calculate the interest"); acc.addInterest(); break; case 'S': case 's': Console.WriteLine("Transaction History"); Console.WriteLine("-------------------"); acc.showTransactions(); break; case 'Q': case 'q': Console.WriteLine("exit"); break; } } } } }

I am so close to getting it correct but I need to fix a couple things. The following is what I need to fix:

This close. A few things that might get it working better.

Execpt for Main, nothing should be static.

You should not redeclare numberOfTransactions in the withdraw method.

The transactions should be placed in Transactions[numberOfTransactions], not 0, 1 and 2.

When you use your array of transactions, stop at numberOfTransactions, not length.

Can someone please show me how I am suppose to do this off of the code that I posted towards the top.

Thank you in advance.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!