View Single Post
  #1  
Old 17-06-2011, 09:53 PM
thecool's Avatar
thecool thecool is offline
Senior Member


 
Join Date: Apr 2009
Location: Multan
Posts: 1,163
Contact Number: Push me a PM if you really need
Program / Discipline: Alumni
Class Roll Number: ---
thecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond repute
Smartass How to write C# student program using grade code

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();
}
}
}

Reply With Quote