JEWELLERY LOAN MANAGEMENT
Aim:
To write a c# program for jewellery loan management system using basic c# concepts.
Algorithm:
Step 1: Include the
necessary namespace and create the user defined classes.
Step 2: Get the user’s
choice and perform computations.
Step 3: If choice is 1,
get jewellery details and debtor details and display the amount of loan
sanctioned for the jewellery.
Step 4: If choice is 2,
display the monthly interest for the loan amount.
Step 5: If choice is 3,
display the details of pending amount if any for the debtor who wish to get
back the jewellery.
Step 6: If choice is 4,
terminate the program.
Program:
using System;
//library declaration
namespace jew_loan
//namespace
{
interface month
//interface declaration
{
void newloan();
//method
}
interface amount
{
void amt();
}
class met1 : month, amount //multiple
inheritance using interface
{
public met1() //constructor
{
p = 0;
}
protected decimal gram; //protected acess specifier
public int loan_no; //public acess specifier
protected decimal p;
#region month Members
public void newloan() //declaring methods of interface
{
try //try block
{
string name, jew_type, address;
Console.WriteLine("enter
the details:");
Console.WriteLine("name:");
name = Console.ReadLine();
Console.WriteLine("address:");
address = Console.ReadLine();
Console.WriteLine("loan
number:");
loan_no =
Convert.ToInt32(Console.ReadLine());
Console.WriteLine("jewel
type");
jew_type = Console.ReadLine();
Console.WriteLine("gram:");
gram =
Convert.ToDecimal(Console.ReadLine());
}
catch (StackOverflowException) { } //catch block
}
#endregion
#region amount Members
public void amt()
{
p = gram * 2000;
Console.WriteLine("loan
sanctioned is {0}", p); //container
}
#endregion
public decimal mon_i;
public int interest;
public void mon()
{
try
{
Console.WriteLine("enter
loan amt:");
p =
Convert.ToDecimal(Console.ReadLine());
if (p < 1000) //if-else selection statement
{
interest = 3;
}
else
interest = 2;
mon_i = (p * interest) / 100;
Console.WriteLine("monthly
interest is" + mon_i);
Console.WriteLine("your
jewel will go to auction if interest is not paid
for 3 months");
}
catch (StackOverflowException) { }
}
}
class met2 : met1
//hierarchical inheritance
{
public
void check()
{
int mon_no;
Decimal total_pay=0;
try
{
Console.WriteLine("enter
loan num:");
loan_no =
Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter
loan amt:");
p =
Convert.ToDecimal(Console.ReadLine());
Console.WriteLine("enter
no of monthly interest not paid:");
mon_no =
Convert.ToInt32(Console.ReadLine());
if (mon_no <= 3)
{
if (p < 1000)
{
interest = 3;
}
else
interest = 2;
mon_i = (p * interest) / 100;
Console.WriteLine("monthly
interest is" + mon_i);
total_pay =(mon_no * mon_i)+ p;
Console.WriteLine("you
have to pay {0} to get your jewel back", total_pay);
}
else
{
Console.WriteLine("you
didnt pay interest for {0} months",mon_no);
Console.WriteLine("your jewel is taken for auction");
}
}
catch (StackOverflowException) { }
}
}
class jewel
{
static void Main(string[] args)
{
met1 n1 = new met1();
met2 n2 = new met2();
int c;
string ch;
Console.WriteLine("\t***welcome to vasantham jewellery***");
do
//do-while iterative statement
{
Console.WriteLine("1.new
loan 2.monthly payment 3.close loan 4.exit \nenter your choice:");
ch = Console.ReadLine();
c= Int32.Parse(ch);
switch (c) //switch control statement
{
case 1: n1.newloan();
n1.amt();
break;
case 2: n1.mon();
break;
case 3: n2.check();
break;
case 4: break;
default: Console.WriteLine("enter
valid choice");
break;
}
} while (c != 4);
}
}
}
Output:
Choice 1:
Result:
Thus the program to
perform jewellery loan management system is executed successfully in c#
program.
No comments:
Post a Comment