Problem definition: design a class BankAccount (accountno, name)
. Inherit this class in FixedDeposit
class which has data members like principal amount (P), rate of interest (R), no. of years (N).
Allow users to input P, R, N and calculate Due Amount (A) and interest (I).
Formulas
A = P(1 + R / 100) ^ N and I = A - P
My code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace prac_18
{
public class BankAccount
{
int accno;
string name;
}
public class FixedDeposit : BankAccount
{
float pamt;
float roi;
int years;
public void getdata(float p,float r,int y)
{
pamt = p;
roi = r;
years = y;
}
public float calc_due()
{
float amt = 0;
amt = pamt * (1 + roi / 100)^years; // Here I get the error
return amt;
}
public float calc_intrest()
{
float intrest = 0;
intrest = calc_due() - pamt;
return intrest;
}
}
}