Question SOLVED: “SquareRootTest”

$30.00

Category:

Description

Question SOLVED: “SquareRootTest”

In C# add to code to prior code down below instructions. Read code “SquareRootTest”.

1. class Program
{

public static double loanAmount;
public static double years;
public static double interest;
static void Main(string[] args)
{

…..
//for loanAmount
do {

}while ( continueLoop );

…..
//for years
do {

}while ( continueLoop );

…..
//for interest
do {

}while ( continueLoop );

}
…..
}

2. Create a class “MyRangeException.cs”.

3. Add Exception Handling
– loanAmount
– must be a number, threw FormatException if not
– must be greater than 50000, throw Exception if not
– Create a method CheckLoanAmount(double la)
throw new MyRangeException(“Loan Amount must be $50,000 or more.”);

– loanInterest
– must be a number, threw FormatException if not
– must be greater than 1%, throw Exception if not
– Create a method CheckLoanInterest(double it)
throw new MyRangeException(“Interest Rate must be 1% or more.”);

– years
– must be a number, threw FormatException if not
– must be greater than 5, throgh Exception if not
– Create a method CheckLoanYears(double yr)
throw new MyRangeException(“Years must be 5 years or more.”);

——————————————————————

Loan code

——————————————————————-

Program.cs

——————————————————————–

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

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine(“Manage Loan Calculation “);

Console.WriteLine(“————————————————————————“);

double a, b, c;
C1 c1 = new C1();
Console.Write(“Enter Loan amount : $”);
a = Convert.ToDouble(Console.ReadLine());
Console.Write(“Enter total years of loan: “);
b = Convert.ToDouble(Console.ReadLine());
Console.Write(“Enter Interest Rate : $”);
c = Convert.ToDouble(Console.ReadLine());

double si = c1.PayInterests(a, b, c);
Console.WriteLine(“Total Interest : $” + si);
Console.WriteLine(“————————————————————————“);

Test t = new Test();
t.iMessage();
Console.ReadKey();
}
interface IT1
{
String iMessage();
}
class Test
{
public void iMessage()
{
Console.WriteLine(“Be Ready…”);

}
}
}

}

————————–

C1.cs

—————————-

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

namespace ConsoleApplication2
{
class C1
{
private double loanAmount, years, interests, interestRate; //private data members.
public double PayInterests(double p, double n, double r)
{
double b;
loanAmount = p;
years = n;
interestRate = r;
b = loanAmount * years * interestRate;
return (b);
}
}
}


error: Content is protected !!