College Application



College Application

Here's a C# program that accepts your educucational information and let's you know if you pass or fail

Here's the code!

                            using System;
                            namespace CollegeApplication
                            {
                                class CollegeApplication
                                {
                                    static void Main(string[] args)
                                    {
                                        string studentName;
                                        double gpa = 0;
                                        double examScore = 0;
                                        Console.Write("Enter your name: ");
                                        studentName = Console.ReadLine();
                                        Console.Write("Enter your GPA: ");
                                        gpa = Convert.ToDouble(Console.ReadLine());
                                        Console.Write("Enter your exam score: ");
                                        examScore = Convert.ToDouble(Console.ReadLine());
                                        try
                                        {
                                            Console.WriteLine("{0}, you {1}", studentName, calc(gpa, examScore));
                                        }
                                        catch(ArgumentException ex)
                                        {
                                            Console.WriteLine(ex.Message);
                                        }
                                    }

                                    public static string calc(double gpa, double examScore)
                                    {
                                        string passOrFail = "";

                                        if(gpa < 0 || gpa > 4 || examScore < 0 || examScore > 100)
                                        {
                                            throw new ArgumentException();
                                        }

                                        if (gpa >= 2.5 && examScore >= 75)
                                        {
                                            passOrFail = "passed";
                                        }
                                        else
                                        {
                                            passOrFail = "failed";
                                        }
                                        return passOrFail;
                                    }
                                }
                            }