//Write a program to calculate simple interest using multilevel inheritance.
using System;
class a
{
public int pi, rate, year, amt, tot;
public void getdata(int p, int r, int n)
{
pi = p;
rate = r;
year = n;
}
}
class b : a
{
public void logic()
{
amt = pi * rate * year / 100;
tot = pi + amt;
Console.WriteLine("Simple Intrest{0}", tot);
}
}
class myclass
{
public static void Main()
{
int p, r, n;
Console.WriteLine("enter principle amount");
p = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter intrest");
r = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter year");
n = Convert.ToInt32(Console.ReadLine());
b b1 = new b();
b1.getdata(p, r, n);
b1.logic();
Console.Read();
}
}
using System;
class a
{
public int pi, rate, year, amt, tot;
public void getdata(int p, int r, int n)
{
pi = p;
rate = r;
year = n;
}
}
class b : a
{
public void logic()
{
amt = pi * rate * year / 100;
tot = pi + amt;
Console.WriteLine("Simple Intrest{0}", tot);
}
}
class myclass
{
public static void Main()
{
int p, r, n;
Console.WriteLine("enter principle amount");
p = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter intrest");
r = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter year");
n = Convert.ToInt32(Console.ReadLine());
b b1 = new b();
b1.getdata(p, r, n);
b1.logic();
Console.Read();
}
}
No comments:
Post a Comment