OOP PrOgrams Here
{student.cs}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace studentClass
{
class student
{
private string Name;
private int Roll_No;
private string Course;
public int Fee_Paid;
public student(string Name, int Roll_No, string Course)
{
this.Name = Name;
this.Roll_No = Roll_No;
this.Course = Course;
}
public void Print_Info()
{
Console.WriteLine("Name:" + Name);
Console.WriteLine("Roll_No:" + Roll_No);
Console.WriteLine("Course:" + Course);
}
public void Payment(int Fee_Paid)
{
this.Fee_Paid += Fee_Paid;
}
public int total_fees
{
get
{
return Course == "C#" ? 6000 : 4000;
}
}
public int Due_Amount
{
get
{
return total_fees - Fee_Paid;
}
}
}
}
PROGRAM
{programe.cs}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace studentClass
{
class Program
{
static void Main(string[] args)
{
student obj = new student("Gul" , 01 , "C#");
obj.Print_Info();
obj.Payment(4000);
obj.Payment(2000);
Console.WriteLine("Total_fees="+obj.total_fees+ " Paid_Fees="+obj.Fee_Paid+ " Dues="+obj.Due_Amount+"\n");
student obj1 = new student("Gul",02,"C++");
obj1.Print_Info();
obj1.Payment(2000);
obj1.Payment(1000);
// obj1.Payment(-1000);
Console.WriteLine("Total_Fess="+obj1.total_fees+ " Paid_Fess="+obj1.Fee_Paid+ " Dues="+obj.Due_Amount+"\n");
student obj2 = new student("Ali", 03, "C#");
obj.Print_Info();
obj.Payment(3000);
obj.Payment(-1000);
Console.WriteLine("Total_fees=" + obj2.total_fees + " Paid_Fees=" + obj2.Fee_Paid + " Dues="+obj.Due_Amount+"\n");
Console.ReadKey();
}
}
}
No comments
Post a Comment