KUTTY
KUTTY
}
}
OUTPUT :
}
public static void main(String a[]){ int[]
arr1={9,14,3,2,43,11,58,22};
System.out.println("Before Selection sort"); for(int
i:arr1){
System.out.println(i+" ");
}
System.out.println();
selectionSort(arr1);
System.out.println("After selection Sort"); for(int
i:arr1){
System.out.println(i+" ");
}
}
}
OUTPUT:
class Stack{
private int arr[];
private int top;
private int capacity;
// Utility function to add an element 'x ' and to the stack public void
push(int x){
if(isFull()){
System.out.println("overflow \n program Terminated \n"); System.exit(-
1);
}
System.out.println("Inserting"+x);
arr[++top]=x;
}
//Utility function to pop element from the stack public int pop(){
if(isEmpty()){
System.out.println("Underflow \n ProgramTerminated");
System.exit(-1);
}
System.out.println("Removing "+peek());
return arr[top--];
}
public int peek(){
if(!isEmpty()){
return arr[top];
}
else{
System.exit(-1);
}
return -1;
}
public int size() {
return top + 1;
}
stack.push(3);
System.out.println("The top element is" +stack.peek());
System.out.println("The stack size is" + stack.size());
stack.pop();
if (stack.isEmpty()){
System.out.println("The stack size is empty"); }
else{
System.out.println("The stack is not empty"); }
}
}
OUTPUT:
Inserting1
Inserting2
Removing 2
Removing 1
Inserting3
Removing 3
if(isQueueFull()){
System.out.println("Queue is full !");
return ;
}
if (rear==maxSize-1){
rear = -1;
}
queueArray[++rear]=item;
currentSize++;
System.out.println("Item added to queue:"+item); }
public int delete(){
if(isQueueEmpty()){
throw new RuntimeException("Queue is empty"); }
int temp= queueArray[front++];
if(front==maxSize){
front=0;
}
currentSize--;
return temp;
}
import java.util.Scanner;
class Employee {
int Emp_id, Mobile_no;
String Emp_name, address, Mail_id;
Scanner get = new Scanner(System.in);
Employee() {
System.out.println("Enter Name of the Employee:");
Emp_name = get.nextLine();
System.out.println("Enter Mail id of the Employee:");
Mail_id = get.nextLine();
System.out.println("Enter Address of the Employee:");
address = get.nextLine();
System.out.println("Enter Emp_ id:");
Emp_id = get.nextInt();
System.out.println("Enter Mobile no:");
Mobile_no = get.nextInt();
}
void display() {
System.out.println("Employee ld: " + Emp_id);
System.out.println("Employee Name:" + Emp_name);
System.out.println("Phone Number: " + Mobile_no);
System.out.println("Mail ld:" + Mail_id);
System.out.println("Address: " + address); }
}
void display() {
System.out.println("Programmer Details" + "\n"); super.display();
System.out.println("Basic Pay: " + bp);
System.out.println("HRA: " + hra);
System.out.println("DA: " + da);
System.out.println("Staff welfare amount:" + swf);
System.out.println("PF: *" + pf);
System.out.println("Salary:" + salary);
}
}
void display() {
System.out.println("Assistant Processor Details " + "\n"); super.display();
System.out.println("Basic Payy:" + bp);
System.out.println("HRA: " + hra);
System.out.println("DA:" + da);
System.out.println("Staff welfare amount: " + swf);
System.out.println("P F: " + pf);
System.out.println("Salary: " + salary);
}
}
AssoProf() {
System.out.println("Enter Basic Pay:");
bp = get.nextFloat();
hra = bp * 10 / 100;
da = bp * 97 / 100;
pf = bp * 12 / 100;
swf = (float) (bp * 0.1 / 100);
salary = bp + da + hra - pf - swf;
}
void display() {
System.out.println("Associate Professor Details'" + "\n"); super.display();
System.out.println("Basic Pay:" + bp);
System.out.println("HRA: " + hra);
System.out.println("DA:" + da);
System.out.println("Staff welfare amount:" + swf);
System.out.println("PF:" + pf);
System.out.println("Salary:" + salary);
}
}
Professor() {
System.out.println("Enter Basic Pay:");
bp = get.nextFloat();
hra = bp * 10 / 100;
da = bp * 97 / 100;
pf = bp * 12 / 100;
swf = (float) (bp * 0.1 / 100);
salary = bp + da + hra - pf - swf;
}
void display() {
System.out.println("Professor Details" + "\n"); super.display();
System.out.println("Basic Pay: " + bp);
System.out.println("HRA: " + hra);
System.out.println("DA: " + da);
System.out.println("Staff welfare amount:" + swf);
System.out.println("P F: " + pf);
System.out.println("Salary:" + salary);
}
}
class Employees {
public static void main(String args[]) {
System.out.println("Enter Programmer Details" + "\n"); Programmer obj1 =
new Programmer();
obj1.display();
AssistProf obj2 = new AssistProf();
obj2.display();
AssoProf obj3 = new AssoProf();
obj3.display();
Professor obj4 = new Professor();
obj4.display();
}
}
OUTPUT:
Programmer Details
Employee ld: 53
Employee Name: JASMINE
Phone Number: 1234567890
Mail ld: [email protected] Address: vanniyambadi
Basic Pay: 100000.0
HRA: 10000.0
DA: 97000.0
Staff welfare amount:100.0
PF: *12000.0
Salary:194900.0
PROGRAM:
interface Shape {
void input();
void area();
}
class Circle implements Shape {
int r = 0;
double pi = 3.14, ar = 0;
main(String args[]) {
try
{
System.out.println(e);
code...");
}
OUTPUT:
java.lang.ArithmeticException: / by zero
MyException(String s) {
super(s);
}
try
{
System.out.println("Caught");
System.out.println(ex.getMessage());
}
OUTPUT:
Caught
exception occurred
PROGRAM:
}
}
public Double getNum() {
return num;
}
t1-0
t1-1
t2--->square of 0.0=0.0 t3---
>Cube of 1.0=1.0 t1-2
t1-3
t2--->square of 2.0=4.0 t3---
>Cube of 3.0=27.0 t1-4
t1-5
t2--->square of 4.0=16.0 t1-6
t1-7
t1-8
PROGRAM:
import java.io. *;
public class FileInfo
{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));System.out.print(" \nEnter A File Name:");
String fName = br.readLine();
File f = new File(fName);
}
else if (fName.endsWith(".exe")) {
System.out.println("The given file is an executable file."); }
else if (fName.endsWith(".txt")) {
System.out.println("The given file is a text file.");
} else
{
simple.text
return t;
Area<Integer> rectangle = new Area <Integer> (); //Object of generics class Area
rectangle.add(10);
circle.add(2.5);
System.out.println(rectangle.get());
System.out.println(circle.get());
}
}
OUTPUT:
10
2.5
PROGRAM:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
@Override
public void start(Stage stage) {
stage.setTitle("HTML");
stage.setWidth(500);
stage.setHeight(500);
Scene scene = new Scene(new Group());
stage.setScene(scene);
stage.show();
}
package application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class MenuExample extends Application { public static
void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception { // TODO Auto-
generated method stub
BorderPane root = new BorderPane();
Scene scene = new Scene(root,200,300);
MenuBar menubar = new MenuBar();
Menu FileMenu = new Menu("File");
MenuItem filemenu1=new MenuItem("new");
MenuItem filemenu2=new MenuItem("Save");
MenuItem filemenu3=new MenuItem("Exit");
Menu EditMenu=new Menu("Edit");
MenuItem EditMenu1=new MenuItem("Cut");
MenuItem EditMenu2=new MenuItem("Copy");
MenuItem EditMenu3=new MenuItem("Paste");
EditMenu.getItems().addAll(EditMenu1,EditMenu2,EditMenu3);
root.setTop(menubar);
FileMenu.getItems().addAll(filemenu1,filemenu2,filemenu3);
menubar.getMenus().addAll(FileMenu,EditMenu);
primaryStage.setScene(scene);
primaryStage.show();
}
}
OUTPUT: