JAVA

PART -A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART-B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

 
  
 
  /*

PART B-2

 Declare an interface containing methods float addition(float x, float y) and float subtraction(float x,
float y). 

Declare the classes implementing the interface to perform respective operations as listed
below.
Bank - to carryout deposit and withdrawal operations. In addition to the implementation for the abstract
methods, the class should contain additional methods to read and display customer information to
perform the respective transaction.

EmployeeSalary - to calculate the gross and net salary. In addition to the implementation for the abstract
methods, the class should contain additional methods to read and display employee information,
allowance amount and deduction amount to perform the respective transaction.

Main class - which instantiates above two classes and calls respective methods.

*/

 
import java.io.*;
import java.util.*;
import java.io.BufferedReader;
 import java.io.IOException;



  
public class program9 {


           
  public static void main(String[] args)
  {
     
    int n = 5,data;
    int ch=0;
    String name ,grade;

     BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
     
 try{
        
          


            Bank b1=new Bank();
            Employee emp1=new  Employee();
             emp1.getname( );

        while(ch!=4){
            System.out.println("Enter 1.Deposite salary  2.withdraw 3.displaybalance  4.exit : ");
       
            ch = Integer.parseInt(reader.readLine());
            switch(ch){

          case 1:
                  int basic=1000;
                 b1.depositsalary(emp1.computeSalary(basic));
                System.out.println("Deposited ");
                   
            break;


        case 2:
                    
                 
             b1.withdrawal();
   

            break;
        case 3:
                 b1.displaybalance();

            break;
        
        case 4:
                ch=4;

            break;


            }



        }

            }catch(Exception e){
        }

  
     
    
   
  }

}




interface operations{
  float addition(float x, float y);
  float subtraction(float x,float y);
}

  class Bank implements operations {

 float balance ;



public void depositsalary(float salary ){  


        try{
 
                   this. balance=addition(balance,salary);

            }catch(Exception e){
                }

}
/*
public void deposit(){  


        try{
         BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));

                    System.out.println("Enter amout to deposit ");
               
                    float  amount = Integer.parseFloat(reader.readLine());

                   this. balance=addition(balance,amount);}catch(Exception e){
                }

}*/


public void withdrawal(){

        try{
         BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));

                    System.out.println("Enter amout to withdrawl ");
               
                    float  amount = Float.parseFloat(reader.readLine());

                  this.  balance=subtraction(balance,amount);

         System.out.println("Balance after withdrawal : "+this.balance);
        }catch(Exception e){
                }

}

public void displaybalance(){

  System.out.println("Current Balance="+balance);

}
public float addition(float x, float y){

    float data=x+y;
    return data;

}
public float subtraction(float x,float y){

    float data=x-y;
    return data;
}



}




  abstract class Person{

public String name;
 public abstract void getname();

}


  class Employee extends Person{
 

public void getname( ){
         try{
         BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));

                    System.out.println("Enter NAME ");
               
                    this.  name = reader.readLine();

          

        }catch(Exception e){
                }
}

public float computeSalary(int basic)
{
    double allowance;
    double hra, da, pf;
     
    hra = 0.2 * basic;
    da = 0.5 * basic;
    pf = 0.11 * basic;
     
     
        allowance = 1700.0;
     
     
    double gross;
     
    // Calculate gross salary
    gross = Math.round(basic + hra + da +  allowance - pf);
                          
    return (float)gross;
}




}