0

```
namespace Exam
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Private void btnCalculate_Click (object sender, System.EvenArgs e)
{
try
{
If (IsValidData());
{
int Numofyrs = Convert.ToInt32(txtnumYrs);
Decimal discountRate = Convert.ToDecimal(txtDuiscountRate);
Decimal yrlyCashFlow = Convert.ToDecimal(txtYrlyCashFlows);
Decimal onetimecosts = Convert.ToDecimal(txtOneTimeCosts);
Decimal yrlyrecurrcosts = Convert.ToDecimal(txtRecurCosts);
npv = CalcNPV(discountRate,yrlyCashFlow,onetimecosts,yrlyrecurrcosts,Numofyrs);
roi = CalcROI(npv,onetimecosts,yrlyrecurrcosts,Numofyrs,discountRate);
bep = CalcBEP(discountRate,yrlyCashFlow,yrlyrecurrcosts,onetimecosts,Numofyrs);
txtOverallNPV.Text=npv.tostring();
txtOverallROI.Text=roi.tostring();
txtBrkEven.Text=bep.tostring();
}
}
catch (Exception ex)
{
MessageBox.Show(ex->Message + "\n\n" +
ex->GetType()->ToString() + "\n" +
ex->StackTrace, "Exception");
}
}
public bool IsValidData()
{
return
IsPresent(txtmNuYears, "Num Yrs") &&
IsInt32(txtNumYears, "Num Yrs") &&
IsWithinRange(txtNumYears, "Num Yrs", 1, 10)&&
IsPresent(txtDuiscountRate, "d rate")&&
IsDecimal(txtDuiscountRate, "d rate")&&
IsRange(txtDuiscountRate, "d rate")&&
IsPresent(txtYrlyCashFlows, "ycf")&&
IsDecimal(txtYrlyCashFlows, "ycf")&&
IsRange(txtYrlyCashFlows, "ycf")&&
IsPresent(txtOneTimeCosts, "otc")&&
IsDecimal(txtOneTimeCosts, "otc")&&
IsRange(txtOneTimeCosts, "otc")&&
IsPresent(txtRecurCosts, "rec cost")&&
IsDecimal(txtRecurCosts, "rec cost")&&
IsRange(txtRecurCosts, "rec cost");
}
public bool IsPresent(TextBox textBox, String name)
{
if (textBox.Text = "")
{
MessageBox.Show(name + " is a required field.", "Entry Error");
textBox.Focus();
return false;
}
return true;
}
public bool IsInt32(TextBox textBox, String name)
{
try
{
Convert.ToInt32(textBox.Text);
return true;
}
catch (FormatException)
{
MessageBox.Show(name + " must be an integer.", "Entry Error");
textBox.Focus();
return false;
}
}
public bool IsWithinRange(TextBox textBox, String name, double min, double max)
{
double number = Convert.ToDouble(textBox.Text);
if (number < min || number > max)
{
MessageBox.Show(name + " must be between " + min
+ " and " + max + ".", "Entry Error");
textBox.Focus();
return false;
}
return true;
}
private decimal CalcNPV(decimal rate, decimal cashflow, decimal onetime, decimal recurring, int year)
{
double sum = 0;
do
{
sum += ((Convert.ToDouble(cashflow - recurring)) / Math.Pow(Convert.ToDouble(1 + rate), Convert.ToDouble(year)));
year--;
} while (year > 0);
return Convert.ToDecimal(sum - Convert.ToDouble(onetime));
}
private decimal CalcROI(decimal npv, decimal recurring, decimal onetime, int year, decimal rate)
{
double sum = 0;
do
{
sum += ((Convert.ToDouble(recurring)) / Math.Pow(Convert.ToDouble(1 + rate), Convert.ToDouble(year)));
year--;
} while (year > 0);
return Convert.ToDecimal(Convert.ToDouble(npv) / (Convert.ToDouble(onetime) + sum));
}
private int CalcBEP(decimal rate, decimal cashflow, decimal recurring, decimal onetime, int year)
{
double sum1 = 0;
double sum2 = 0;
int i = 0;
do
{
sum1 += ((Convert.ToDouble(cashflow)) / Math.Pow(Convert.ToDouble(1 + rate), Convert.ToDouble(year)));
sum2 += ((Convert.ToDouble(recurring)) / Math.Pow(Convert.ToDouble(1 + rate), Convert.ToDouble(year)));
i++;
if ((sum1 - sum2) - Convert.ToDouble(onetime) > 0)
break;
else if (i == 100)
break;
else
onetime -= Convert.ToDecimal((sum1 - sum2));
}while(i >= 0);
return i;
}}}
```

the error is in "Private void btnCalculate_Click (object sender, System.EvenArgs e)"

it says invalid token void in class, struct, or interface member decleration