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

namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
//grading system: 100-90 A, 90-80 B, 80-70 C, 70-60 D, 60-0 Failed

ReInput: Console.WriteLine(“please input your score”);
string str1 = Console.ReadLine();

int score = 0;
bool hasErrors = false;
try
{
score = int.Parse(str1);
}
catch (OverflowException aoe)
{
Console.WriteLine(aoe.Message);
hasErrors = true;

}
catch (NullReferenceException nre)
{
Console.WriteLine(nre.Message);
hasErrors = true;

}
catch (FormatException fe)
{
Console.WriteLine(fe.Message);
hasErrors = true;

}
finally
{

if (hasErrors)
{
Console.WriteLine(“your input has errors”);
}
else
{
Console.WriteLine(“done”);
}
}

if (score >= 90 && score <= 100)
{
Console.WriteLine(“A”);
}
else if (score >= 80 && score < 90)
{
Console.WriteLine(“B”);
}
else if (score >= 70 && score < 80)
{
Console.WriteLine(“C”);
}
else if (score >= 60 && score < 70)
{
Console.WriteLine(“D”);
}
else if (score >= 0 && score < 60)
{
Console.WriteLine(“Failed”);
}
else
{
Console.WriteLine(“please re-check your input number”);
}

goto ReInput;
}
}
}

Advertisements