Student program | using grade code
Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace result
{
class stud
{
public int roll, total, avg, dbms, c, cpp, vb;
string name, grade;
public void getdata()
{
Console.WriteLine("Enter roll no.:");
roll = int.Parse(Console.ReadLine());
Console.WriteLine("Enter name:");
name = Console.ReadLine();
Console.WriteLine("Enter marks in DBMS:");
dbms = int.Parse(Console.ReadLine());
Console.WriteLine("Enter marks in C:");
c = int.Parse(Console.ReadLine());
Console.WriteLine("Enter marks in CPP:");
cpp = int.Parse(Console.ReadLine());
Console.WriteLine("Enter marks in VB:");
vb = int.Parse(Console.ReadLine());
}
public void putdata()
{
total = (dbms + c + cpp + vb);
avg = total / 4;
if (avg >= 70)
grade = "distinction";
else if (avg >= 60)
grade = "first class";
else if (avg >= 50)
grade = "second class";
else if (avg >= 40)
grade = "Pass class";
else
grade = "Fail";
Console.WriteLine("Roll No: " + roll);
Console.WriteLine("Name: " + name);
Console.WriteLine("Marks in DBMS: " + dbms);
Console.WriteLine("Marks in C: " + c);
Console.WriteLine("Marks in CPP: " + cpp);
Console.WriteLine("Marks in VB: " + vb);
Console.WriteLine("Total: " + total);
Console.WriteLine("Average: " + avg);
Console.WriteLine("Grade: " + grade);
}
static void Main(string[] args)
{
stud ob = new stud();
ob.getdata();
ob.putdata();
console.readline();
}
}
}