Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# with visual studios Create a base class (Account.cs) with the following chara

ID: 3689221 • Letter: C

Question

C# with visual studios

Create a base class (Account.cs) with the following characteristics:

o A member that stores a double for the account balance
o A member that stores an integer for the account number.
o A constructor that takes an integer for the account number.
   Make the default constructor private so that all accounts have an associated account number

o Initialize the account balance to 0.0. o Create the following methods:
      Deposit
  
• Takes the amount to deposit

   Withdraw
     
Takes the amount to withdraw
     
Checks against a neg. balance

o Create the following properties:
Account Balance – get; only § Account Number – get; only
   ToString –
  
return "Account " + accountNumber + ": " + "balance = " + balance;

Create a derived class for a Savings Account (SavingsAccount.cs) with the following characteristics:

o An interest variable
o A method that adds interest to the account
o An override to the ToString method that prints out the interest rate along with the other
things in the base class ToString formula

Create a Form that:
o Allows you to create an account (using a random account number)
   Use the Math.Random class to accomplish this

o Allows the user to make a deposit
o Allows the user to make a withdrawal
o Always shows current status of the account after an event.
   I should always know what account I am dealing with, my interest rate, and my balance.

o Calculates/estimate interest earned over a user-specified period (in years) given a user specified interest rate.
   Use the Simple interest formula: A = P(1 + rt)

Check your values here: http://www.calculatorsoup.com/calculators/financial/simple- interest-plus-principal-calculator.php

Explanation / Answer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace bank_transaction_cs
{
  

public partial class Form1 : Form
{
  

public Form1()
{
InitializeComponent();
Random r=new Random ();
textBox1.Text =r.Next ().ToString ();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
double a;
if (radioButton1.Checked )
{
a = Convert.ToDouble ( textBox3.Text) + Convert.ToDouble ( textBox2.Text);
textBox3.Text = a.ToString();
}
if (radioButton2.Checked )
{
a= Convert.ToDouble ( textBox3.Text) - Convert.ToDouble ( textBox2.Text);
textBox3.Text = a.ToString();
}
}
}
public class Accounts
{
public double accbal;
public int accno;
public Accounts(int acno)
{
accno = acno;
}
private Accounts()
{
accbal = 0;
}
void Deposit(double amt)
{
accbal = accbal + amt;
}
void Withdraw(double amt)
{
accbal = accbal - amt;
}
double getAccountBalance()
{
return accbal;
}
int getAccountNumber()
{
return accno;
}
public override String ToString()
{
return "Account" + accno + ":" + "balance=" + accbal;
}
}
public class SavingsAccount : Accounts
{
int interest;
void addint(double inte)
{
accbal=accbal+inte;
}
public override string ToString()
{
return base.ToString();
}
}
}