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

C# project - ArgumentException is an existing class that derives from Exception;

ID: 3763620 • Letter: C

Question

C# project - ArgumentException is an existing class that derives from Exception; you use it when one or more of a method’s arguments do not fall within an expected range. Create an application for Midtown College named CollegeApplication containing variables that can hold a student’s name, high school grade point average, and entrance examination score. Within the class, create a method that accepts parameters for the student’s grade point average and test score and returns true or false indicating whether the student is accepted to the college. A student is accepted when his grade point average is at least 2.5 and his test score is at least 75. If the grade point average is not between 0.0 and 4.0 inclusive or the test score is not between 0 and 100 inclusive, throw an ArgumentException from the method. In the Main() method, continuously prompt the user for student data. Call the method that determines college acceptance, and then display an appropriate message based on the returned value.

Explanation / Answer

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

namespace CollegeApplication
{
class Program
{
static Boolean check(double h, double e)
{
if (h >= 2.5 && e >= 75)
return true;
else
return false;
}

static void Main(string[] args)
{
Boolean ans;
String name;
double hi_grade, ex_score;

Console.WriteLine("Enter name");
name = Console.ReadLine();

Console.WriteLine("Enter High School Grade point aveage");
hi_grade = Convert.ToDouble( Console.ReadLine());

Console.WriteLine("Enter Examamination score");
ex_score = Convert.ToDouble( Console.ReadLine());

ans=check(hi_grade, ex_score);
if (ans)
{
Console.WriteLine("You can get Admission");
}
else
{
Console.WriteLine("You cannot get Admission");
}
Console.ReadKey();
}
}
}