import java.io.*;
interface AddSub
{
public float add( float a);
public float sub(float b);
}
class Customer implements AddSub
{
float balance=10000.00f;
public float add( float a)
{
balance=balance+a;
return balance;
}
public float sub(float b)
{
if(balance>=b)
balance=balance - b;
else
System.out.println("Invalid Amount!");
return balance;
}
}
class Bank implements AddSub
{
float BasicSal=10000.00f;
public float add( float hike)
{
BasicSal=BasicSal+(BasicSal*hike)/100;
return BasicSal;
}
public float sub(float ded)
{
if(BasicSal>=ded)
BasicSal=BasicSal - ded;
else
System.out.println("Invalid Amount!");
return BasicSal;
}
}
class Main12
{
public static void main(String args[])throws IOException
{
Customer cust=new Customer();
Bank ba=new Bank();
for(;;)
{
System.out.println("1.Deposit \n2.Withdraw \n3.Salary Hike \n4.Salary Deduction \n5.Exit");
System.out.println("Enter your choice:");
int ch;
float dep,with,hike,ded;
DataInputStream in=new DataInputStream(System.in);
ch=Integer.parseInt(in.readLine());
switch(ch)
{
case 1: System.out.println("Enter the amount to deposit:");
dep=Float.valueOf(in.readLine()).floatValue();
System.out.println("Previous balance:"+cust.balance);
cust.balance=cust.add(dep);
System.out.println("Balance after depositing "+dep+" is Rs."+cust.balance);
break;
case 2: System.out.println("Enter the amount to withdraw:");
with=Float.valueOf(in.readLine()).floatValue();
System.out.println("Available balance:"+cust.balance);
cust.balance=cust.sub(with);
System.out.println("Balance after withdrawing "+with+" is Rs."+cust.balance);
break;
case 3: System.out.println("Enter salary hike in percentage:");
hike=Float.valueOf(in.readLine()).floatValue();
System.out.println("Existing salary:"+ba.BasicSal);
ba.BasicSal=ba.add(hike);
System.out.println("Salary after a hike of "+hike+" % is Rs."+ba.BasicSal);
break;
case 4: System.out.println("Enter amount to deduct:");
ded=Float.valueOf(in.readLine()).floatValue();
System.out.println("Existing salary:"+ba.BasicSal);
ba.BasicSal=ba.sub(ded);
System.out.println("Salary after deducting "+ded+" is Rs."+ba.BasicSal);
break;
default:
System.exit(0);
}
}
}
}
interface AddSub
{
public float add( float a);
public float sub(float b);
}
class Customer implements AddSub
{
float balance=10000.00f;
public float add( float a)
{
balance=balance+a;
return balance;
}
public float sub(float b)
{
if(balance>=b)
balance=balance - b;
else
System.out.println("Invalid Amount!");
return balance;
}
}
class Bank implements AddSub
{
float BasicSal=10000.00f;
public float add( float hike)
{
BasicSal=BasicSal+(BasicSal*hike)/100;
return BasicSal;
}
public float sub(float ded)
{
if(BasicSal>=ded)
BasicSal=BasicSal - ded;
else
System.out.println("Invalid Amount!");
return BasicSal;
}
}
class Main12
{
public static void main(String args[])throws IOException
{
Customer cust=new Customer();
Bank ba=new Bank();
for(;;)
{
System.out.println("1.Deposit \n2.Withdraw \n3.Salary Hike \n4.Salary Deduction \n5.Exit");
System.out.println("Enter your choice:");
int ch;
float dep,with,hike,ded;
DataInputStream in=new DataInputStream(System.in);
ch=Integer.parseInt(in.readLine());
switch(ch)
{
case 1: System.out.println("Enter the amount to deposit:");
dep=Float.valueOf(in.readLine()).floatValue();
System.out.println("Previous balance:"+cust.balance);
cust.balance=cust.add(dep);
System.out.println("Balance after depositing "+dep+" is Rs."+cust.balance);
break;
case 2: System.out.println("Enter the amount to withdraw:");
with=Float.valueOf(in.readLine()).floatValue();
System.out.println("Available balance:"+cust.balance);
cust.balance=cust.sub(with);
System.out.println("Balance after withdrawing "+with+" is Rs."+cust.balance);
break;
case 3: System.out.println("Enter salary hike in percentage:");
hike=Float.valueOf(in.readLine()).floatValue();
System.out.println("Existing salary:"+ba.BasicSal);
ba.BasicSal=ba.add(hike);
System.out.println("Salary after a hike of "+hike+" % is Rs."+ba.BasicSal);
break;
case 4: System.out.println("Enter amount to deduct:");
ded=Float.valueOf(in.readLine()).floatValue();
System.out.println("Existing salary:"+ba.BasicSal);
ba.BasicSal=ba.sub(ded);
System.out.println("Salary after deducting "+ded+" is Rs."+ba.BasicSal);
break;
default:
System.exit(0);
}
}
}
}
No comments :
Post a Comment