C# Write compile and test a program named CollegeApplication. The requirements f
ID: 3688738 • Letter: C
Question
C#
Write compile and test a program named CollegeApplication. The requirements for this application are as follows:
• The application shall contain variables of appropriate types to hold:
a. A student’s name,
b. High school grade point average, and
c. Entrance examination score.
• 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
. • 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. 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. [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.]
Explanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CollegeApplication
{
class Program
{
public static bool colladd(double g, double s)
{
if (g >= 2.5 && s >= 75)
return true;
else
return false;
}
static void Main(string[] args)
{
String name;
double grade, score;
String c;
while (true)
{
Console.WriteLine("Enter student name");
name = Console.ReadLine();
Console.WriteLine("Enter GPA");
grade = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter exam score");
score = Convert.ToDouble(Console.ReadLine());
bool ans = colladd(grade, score);
if (ans)
{
Console.WriteLine("Addmission accepted");
}
else
Console.WriteLine("Addmission rejected");
Console.ReadKey();
Console.WriteLine("Any more student [y/n]");
c = Console.ReadLine ();
if (c == "n")
break;
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.