using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class CalcAvgPerc //Calculate the Average marks and percentage for students
{
public float maths, science, english, physics, chemistry;
public float average, percentage, total = 500f;
static void Main(string[] args)
{
String StudentName;
Console.WriteLine("Enter the name for Student to Calculate the Average and Percentage");
StudentName = Console.ReadLine();
Console.WriteLine("Creating Report for the student :{0}", StudentName);
System.Threading.Thread.Sleep(5000);
Console.WriteLine("Validating Marks....");
CalcAvgPerc a = new CalcAvgPerc();
a.abc();
}
public void abc()
{
Console.WriteLine("Enter Marks for Maths for range 0-100");
maths = float.Parse(Console.ReadLine());
Console.WriteLine("Enter Marks for Science for range 0-100");
science = float.Parse(Console.ReadLine());
Console.WriteLine("Enter Marks for English for range 0-100");
english = float.Parse(Console.ReadLine());
Console.WriteLine("Enter Marks for Physics for range 0-100");
physics = float.Parse(Console.ReadLine());
Console.WriteLine("Enter Marks for Chemistry for range 0-100");
chemistry = float.Parse(Console.ReadLine());
if ((maths >= 0 && maths <= 100) && (science >= 0 && science <= 100) && (english >= 0 && english <= 100) && (physics >= 0 && physics <= 100) && (chemistry >= 0 && chemistry <= 100))
{
System.Threading.Thread.Sleep(3000);
average = (maths + science + english + physics + chemistry) / total;
Console.WriteLine("Average score is :{0}", average);
percentage = average * 100;
Console.WriteLine("Percentage obtained by student is: {0}", percentage);
Console.ReadLine();
}
else
{
Console.WriteLine("Marks Entered are incorrect...Re-enter the Marks");
abc();
}
}
}
}This program is designed to re-enter all marks again if marks entered are incorrect.
