Posts

Showing posts from August, 2018

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY-STACK ADT USING JAVA ARRAY WITH EXCEPTION HANDLING

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY QUESTION: Design a Java interface for ADT Stack. Implement this interface using array. Provide necessary exception handling in both the implementations. Program: import java.io.*; interface Mystack {     public void pop();     public void push();     public void display(); } class Stack_array implements Mystack {     final static int n=5;     int stack[]=new int[n];     int top=-1;     public void push()     {         try         {             BufferedReader br=new BufferedReader(new InputStreamReader(System.in));             if(top==(n-1))             {                 System.out.println(" Stack Overflow");                 ...

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY-USING ABSTRACT CLASS

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY QUESTION:Write a Java Program to create an abstract class named Shape that contains two integers and an empty method named print Area(). Provide three classes named Rectangle, Triangle and Circle such that each one of the classes extends the class Shape. Each one of the classes contains only the method print Area () that prints the area of the given shape. Program: import java.util.Scanner; abstract class Shape{ int A=10,B=5; abstract void Area(); } class Rectangle extends Shape{ void Area(){ System.out.println("Area of an rectangle (area=Length*width)"+A*B); } } class Triangle extends Shape{ void Area(){ System.out.println("Area of an Triangle (area=0.5*height*base)"+0.5*A*B); } } class Circle extends Shape{ void Area(){ System.out.println("Area of a circle is (a=3.14*a*a)"+3.14*A*A); } } class Findarea{ public static void main(String args[]){ Shape obj=new Rec...

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY-JAVA EMPLOYEE PROGRAM USING INHERITANCE CONCEPT FOR

CS8382-OBJECT ORIENTED PROGRAMMING LABORATORY Develop a java application with Employee class with Emp_name, Emp_id, Address, Mail_id, Mobile_no as members. Inherit the classes, Programmer, Assistant Professor, Associate Professor and Professor from employee class. Add Basic Pay (BP) as the member of all the inherited classes with 97% of BP as DA, 10 % of BP as HRA, 12% of BP as PF, 0.1% of BP for staff club fund. Generate pay slips for the employees with their gross and net salary. PROGRAM: import java.util.Scanner; class Employee{ String Emp_name; int Emp_id; String Address; String Mail_id; int Mobile_no; void display(){ System.out.println(Emp_name); //Syetem.out.println(Address); System.out.println(Emp_id); System.out.println(Mail_id); System.out.println(Mobile_no); } } class Programmer extends Employee{    int BP;  /*int  DA= (int) (0.97*BP);  HRA=(int) (0.10*BP);  PF=(int) (0.12*BP);  */ ...