Follow us on Facebook

Header Ads

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Javat2point

Welcome to JAVA POint

slider

 




Flutter

 Flutter is a hybrid making the technology it is used to make web application Android application and iOS Application easy and fast devlopment using this technology flutter is number of jobs is very high and paying in India or all over world 🌎 if are interested learn flutter if you have any queries i will answer you

BCA (SCIENCE) JAVA PRACTICAL SLIPS PAGES.(JAVA)

 

 UNIVERSITY OF PUNE

BCA (SCIENCE) JAVA  PRACTICAL SLIPS  PAGES.

 

// slip 1. Q1 //Find max element of an array//

import java.io.*;

class slip1_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int max,i,n;

int a[]=new int[10];

System.out.print("enter a how many element you want= ");

n=Integer.parseInt(br.readLine());

for(i=0;i<n;i++)

{

System.out.print("enter a element = ");

a[i]=Integer.parseInt(br.readLine());

}

max=a[0];

for(i=0;i<n;i++)

{

if(max<a[i])

{

max=a[i];

}

}

System.out.println("\nTHE MAX ELEMENT IS= "+max);

}

}

 

/*================OUTPUT===============

smj@smj-virtual-machine:~$ javac Max.java

smj@smj-virtual-machine:~$ java Max

enter a how many element you want= 4

enter a element = 12

enter a element = 3

enter a element = 24

enter a element = 54

THE MAX ELEMENT IS= 54

smj@smj-virtual-machine:~$

*/

//slip 1_2

import java.io.*;

abstract class shape

{

abstract void calc_area();

abstract void calc_volume();

}

class sphere extends shape

{

int radius;

double a;

public sphere(int radius)

{

this.radius=radius;

}

 

public void calc_area()

{

a=4*3.14*radius*radius;

System.out.println("\nThe Area of sphere is = "+a);

}

public void calc_volume()

{

double v;

v=4*3.14*radius*radius*radius;

System.out.println("\nThe volume of sphere is = "+v);

}

}

 

class box extends shape

{

public int hight;

public int breadth;

public int length;

public box(int hight,int breadth,int length)

{

this.hight=hight;

this.breadth=breadth;

this.length=length;

}

 

public void calc_area()

{

double a;

a=2*(hight*breadth)+2*(hight*length)+2*(breadth*length);

System.out.println("\nThe Area of box is = "+a);

}

public void calc_volume()

{

double v;

v=hight*breadth*length;

System.out.println("\nThe Volume of box = "+v);

}

}

 

class slip1_2

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int r,l,b,h;

System.out.print("enter a radius of sphere = ");

r=Integer.parseInt(br.readLine());

sphere ob1=new sphere(r);

ob1.calc_area();

ob1.calc_volume();

 

System.out.print("enter a length of box = ");

l=Integer.parseInt(br.readLine());

System.out.print("enter a breadth of box = ");

b=Integer.parseInt(br.readLine());

System.out.print("enter a hight box = ");

h=Integer.parseInt(br.readLine());

box ob2=new box(l,b,h);

ob2.calc_area();

ob2.calc_volume();

System.out.println();

}

}

 

/*=================OUTPUT============

smj@smj-virtual-machine:~$ javac slip1_2.java

smj@smj-virtual-machine:~$ java slip1_2

enter a radius of sphere = 3

 

The Area of sphere is = 113.03999999999999

 

The volume of sphere is = 339.12

enter a length of box = 2

enter a breadth of box = 2

enter a hight box = 2

 

The Area of box is = 24.0

 

The Volume of box = 8.0

 

smj@smj-virtual-machine:~$

*/

 

**

// ======= slip1_3 =========//

 

import javax.swing.*;

import java.awt.*;

class panel

{

public static void main(String arg[])

{

JFrame f=new JFrame("panel");

JLabel l1=new JLabel("Font");

l1.setBounds(10,40,100,30);

String color[]={"Aril","Black","Red","Green","Gray"};

JComboBox cb1=new JComboBox(color);

cb1.setBounds(10,70,70,30);

 

JLabel l2=new JLabel("Size");

l2.setBounds(10,120,100,30);

String Size[]={"10","20","30","40","50"};

JComboBox cb2=new JComboBox(Size);

cb2.setBounds(10,150,70,30);

 

JTextField t=new JTextField();

t.setBounds(10,200,250,30);

 

JLabel l3=new JLabel("Style");

l3.setBounds(150,40,100,30);

JCheckBox b1=new JCheckBox("Bold");

b1.setBounds(150,70,100,30);

JCheckBox b2=new JCheckBox("Italic");

b2.setBounds(150,100,100,30);

JCheckBox b3=new JCheckBox("Underline");

b3.setBounds(150,130,100,30);

 

 

 

f.add(l1);

f.add(cb1);

f.add(l2);

f.add(cb2);

f.add(t);

f.add(l3);

f.add(b1);

f.add(b2);

f.add(b3);

f.setSize(300,300);

f.setLayout(null);

f.setVisible(true);

}

}

//slip 4_1//

import java.io.*;

class slip4_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int a,b;

System.out.print("enter a two no = ");

a=Integer.parseInt(br.readLine());

b=Integer.parseInt(br.readLine());

 

int c=a+b;

 

System.out.println("\nthe sum is "+c);

}

}

 

/*================output===========

smj@smj-virtual-machine:~$ javac slip4_1.java

smj@smj-virtual-machine:~$ java slip4_1

enter a two no = 5

6

 

the sum is 11

smj@smj-virtual-machine:~$

 

*/

//slip 4_2//

import java.io.*;

class person

{

int pid,age;

String pname,gender;

 

public person(int pid,String pname,int age,String gender)

{

this.pid=pid;

this.pname=pname;

this.age=age;

this.gender=gender;

}

 

public String toString()                   

{

return pid+" "+pname+" "+age +" "+gender;

}

}

 

class slip4_2

{

public static void main(String arg[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int pi,ag,n,i;

String pn,gen;

System.out.print("enter a how many person = ");

n=Integer.parseInt(br.readLine());

 

person obj[]=new person[n];

 

for(i=0;i<n;i++)

{

System.out.print("enter a pid = ");

pi=Integer.parseInt(br.readLine());

System.out.print("enter a pname = ");

pn=br.readLine();

System.out.print("enter a age = ");

ag=Integer.parseInt(br.readLine());

System.out.print("enter a gender = ");

gen=br.readLine();

System.out.println();

obj[i]=new person(pi,pn,ag,gen);

}

 

System.out.println("\nDisplay person details\n");

for(i=0;i<n;i++)

{

System.out.println(obj[i]);

}

}

}

 

/*==========output================

 

smj@smj-virtual-machine:~$ javac slip4_2.java

smj@smj-virtual-machine:~$ java slip4_2

enter a how many person = 2

enter a pid = 111

enter a pname = jagdish

enter a age = 19

enter a gender = male

 

enter a pid = 222

enter a pname = ankit

enter a age = 20

enter a gender = male

 

 

Display person details

 

111 jagdish 19 male

222 ankit 20 male

smj@smj-virtual-machine:~$ */

..

//========== slip 4_3 ========//

import java.io.*;

class slip4_3

{

public static void main(String arg[])throws IOException

 

 {

 

File in1=new File("f1.txt");

 

File in2=new File("f2.txt");

 

File in3=new File("f3.txt");

 

 

FileReader fr1=new FileReader(in1);

 

 FileWriter fw1=new FileWriter(in2);

 

int ch;

 

 while((ch=fr1.read())!=-1)

 

 {

  

char c=(char)ch;

  

if(Character.isUpperCase(c))

   

{

    

c=Character.toLowerCase(c);

 

     fw1.write(c);

 

   }

  

else if(Character.isLowerCase(c))

  

{

    

c=Character.toUpperCase(c);

    

fw1.write(c);

  

}

 

else

 

 {

   

fw1.write(c);

 

}

 

}

 

 

fw1.close();

 

 

FileReader r1=new FileReader(in1);

 

 FileWriter w1=new FileWriter(in3);

 

 

while((ch=r1.read())!=-1)

 

{

 

char c=(char)ch;

 

w1.write(c);

 

 }

 

r1.close();

 

 

 

 FileReader r2=new FileReader(in2);

 

 

 while((ch=r2.read())!=-1)

 

{

  

char c=(char)ch;

  

w1.write(c);

 

 }

 

r2.close();

 

 w1.close();

 

}

 

}

 

 

/*================= Output===============

 

 

/*****************f1.txt*******************

 

asdsdf  sdjfsdf saduf sdfsdf;

s

df sdfsdf

 sdhfsd

f sadfsdfhs fisf sdf sdfsdsljfsad

fpsdfoshdf

 

DFG

DFGH

DH

  DHHJ

 DFGN SHOH FG SDFH OSHDFC HSDHFSDHFH SDFSHDF

 

 

/*****************f2.txt********************

 

ASDSDF  SDJFSDF SADUF SDFSDF;

S

DF SDFSDF

 SDHFSD

F SADFSDFHS FISF SDF SDFSDSLJFSAD

 FPSDFOSHDF

 

dfg

dfgh

dh

  dhhj

 dfgn shoh fg sdfh oshdfc hsdhfsdhfh sdfshdf

 

 

/*****************f3.txt********************

 

 

asdsdf  sdjfsdf saduf sdfsdf;

s

df sdfsdf

 sdhfsd

f sadfsdfhs fisf sdf sdfsdsljfsad

fpsdfoshdf

 

DFG

DFGH

DH

  DHHJ

 DFGN SHOH FG SDFH OSHDFC HSDHFSDHFH SDFSHDF

 

ASDSDF  SDJFSDF  SADUF SDFSDF;

S

DF SDFSDF

 SDHFSD

F SADFSDFHS FISF SDF SDFSDSLJFSAD FPSDFOSHDF

 

 

dfg

dfgh

dh

  dhhj

 dfgn shoh fg sdfh oshdfc hsdhfsdhfh sdfshdf

*/

….

//slip 5_1//

 

import java.io.*;

class slip5_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

 

String str1,rev="";

System.out.println();

System.out.print("enter a orignal String = ");

str1=br.readLine();

int len=str1.length();

int i;

for(i=len-1;i>=0;i--)

{

rev=rev+str1.charAt(i);

}

if(str1.equals(rev))

{

System.out.println("String is palindrom\n");

}

else

{

System.out.println("String is not palindrom\n");

}

}

}

 

/*=====================output==============

smj@smj-virtual-machine:~$ javac slip5_1.java

smj@smj-virtual-machine:~$ java slip5_1

 

enter a orignal String = nitin

String is palindrom

 

smj@smj-virtual-machine:~$ javac slip5_1.java

smj@smj-virtual-machine:~$ java slip5_1

 

enter a orignal String = neha

String is not palindrom

 

smj@smj-virtual-machine:~$

*/

//===slip 5_2====//

 

 

import java.io.*;

 

class IncorrectPassword extends Exception

{

 

}

 

 

class slip5_2

 

{

 

  public static void main(String ar[])throws IOException

 

{

   

String u_name="google";

   

String password="google@123";

   

String un,pass;

 

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

 

System.out.print("\nenter a user name = ");

 

un=br.readLine();

 

System.out.print("enter a password = ");

 

pass=br.readLine();

 

try

 

{

 

if(u_name.equals(un) || password.equals(pass))

  

{

   

System.out.println("\nUser Name and Password are valid\n");

 

   }

 

else

 

  {

 

     throw new IncorrectPassword();

 

   }

 

}

 

catch(IncorrectPassword e)

 

{

 

System.out.println("\nIncorrect Password Exception\n");

 

}

 

}

 

}

/*===============output====================

smj@smj-virtual-machine:~$ javac slip5_2.java

smj@smj-virtual-machine:~$ java slip5_2

enter a user name = google

enter a password = google@123

User Name and Password are valid

      OR

smj@smj-virtual-machine:~$ javac slip5_2.java

smj@smj-virtual-machine:~$ java slip5_2

enter a user name = smj

enter a password = smj@123

Incorrect Password Exception*/

//========= slip 6_1=====//

 

import java.io.*;

class slip6_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int sum=0;

double avg;

int a[]=new int[12];

int n,i;

System.out.print("Enter a how many no = ");

n=Integer.parseInt(br.readLine());

for(i=0;i<n;i++)

{

System.out.print("Enter a  no = ");

a[i]=Integer.parseInt(br.readLine());

 

sum=sum+a[i];

}

avg=sum/n;

System.out.println();

System.out.println("The mean of array is = " +avg);

System.out.println();

}

}

 

/*===============output===============

smj@smj-virtual-machine:~$ javac slip6_1.java

smj@smj-virtual-machine:~$ java slip6_1

Enter a how many no = 4

Enter a  no = 1

Enter a  no = 2

Enter a  no = 3

Enter a  no = 4

 

The mean of array is = 2.0

 

smj@smj-virtual-machine:~$*/

//=======slip 5_3=======//

 

import java.io.*;

abstract class staff

{

String name,add;

}

 

class fulltimestaff extends staff

{

String dept;

double salary;

fulltimestaff(String name,String add,String dept,double salary)

{

this.name=name;

this.add=add;

this.dept=dept;

this.salary=salary;

}

 

void disp()

{

System.out.println();

System.out.println("Name is = " +name);

System.out.println("address is = "+add);

System.out.println("department is = "+dept);

System.out.println("salary is "+salary);

System.out.println();

}

}

 

class parttimestaff extends staff

{

int no_of_hr;

int r_p_hr;

parttimestaff(String name,String add,int no_of_hr,int r_p_hr)

{

this.name=name;

this.add=add;

this.no_of_hr=no_of_hr;

this.r_p_hr=r_p_hr;

}

 

void disp()

{

System.out.println("Name is = " +name);

System.out.println("address is = "+add);

System.out.println("no_of_hr is = "+no_of_hr);

System.out.println("r_p_hr is "+r_p_hr);

System.out.println();

}

}

 

class slip5_3

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

String nm,ad,dp;

double sal;

int nh,rh;

int n,ch;

do

{

System.out.println("1:full time staff");

System.out.println("2:part time staff");

System.out.print("Enter your choices = ");

ch=Integer.parseInt(br.readLine());

switch(ch)

{

case 1:

System.out.println();

System.out.print("Enter how many full time staff = ");

n=Integer.parseInt(br.readLine());

fulltimestaff obj1[]=new fulltimestaff[n];

int i;

for(i=0;i<n;i++)

{

System.out.print("Enter a Name  = ");

nm=br.readLine();

System.out.print("Enter  address  = ");

ad=br.readLine();

System.out.print("Enter department  = ");

dp=br.readLine();

System.out.print("Enter salary  = ");

sal=Double.parseDouble(br.readLine());

System.out.println();

 

obj1[i]=new fulltimestaff(nm,ad,dp,sal);

}

System.out.println("======Details of full time staff===========");

for(i=0;i<n;i++)

{

obj1[i].disp();

}

break;

 

case 2:

int m,j;

System.out.print("Enter how many part time staff = ");

m=Integer.parseInt(br.readLine());

parttimestaff obj2[]=new parttimestaff[m];

 

for(j=0;j<m;j++)

{

System.out.println();

System.out.print("Enter a Name  = ");

nm=br.readLine();

System.out.print("Enter  address  = ");

ad=br.readLine();

System.out.print("Enter no_of_hr  = ");

nh=Integer.parseInt(br.readLine());

System.out.print("Enter a rate_per_hr = ");

rh=Integer.parseInt(br.readLine());

System.out.println();

 

obj2[j]=new parttimestaff(nm,ad,nh,rh);

}

System.out.println("==========Details of part time staff===========");

for(j=0;j<m;j++)

{

obj2[j].disp();

}

break;

default:System.out.println("Invalid choices = ");

}

}while(ch!=2);

}

}

 

/*===============output===================

smj@smj-virtual-machine:~$ javac slip5_3.java

smj@smj-virtual-machine:~$ java slip5_3

1:full time staff

2:part time staff

Enter your choices = 1

 

Enter how many full time staff = 2

Enter a Name  = janvi

Enter  address  = kharadi

Enter department  = manager

Enter salary  = 6000000

 

Enter a Name  = jagdish

Enter  address  = kharadi

Enter department  = IT cyber security

Enter salary  = 700000

 

======Details of full time staff===========

 

Name is = janvi

address is = kharadi

department is = manager

salary is 6000000.0

 

 

Name is = jagdish

address is = kharadi

department is = IT cyber security

salary is 700000.0

 

1:full time staff

2:part time staff

Enter your choices = 2

Enter how many part time staff = 2

 

Enter a Name  = Neha varma          

Enter  address  = EON pune

Enter no_of_hr  = 9

Enter a rate_per_hr = 50

 

 

Enter a Name  = Ankit pawar

Enter  address  = magarpatta city

Enter no_of_hr  = 8

Enter a rate_per_hr = 40

 

==========Details of part time staff===========

 

Name is = Neha varma

address is = EON pune

no_of_hr is = 9

r_p_hr is 50

 

Name is = Ankit pawar

address is = magarpatta city

no_of_hr is = 8

r_p_hr is 40

*/

//========= slip 6_2 ========//

 

 

import java.io.*;

 

import java.io.RandomAccessFile;

 

class slip6_2

 

{

 

public static void main(String arg[])throws IOException

 

{

 

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

 

File f1=new File("a.c");

 

FileReader fr=new FileReader(f1);

 

 

RandomAccessFile raf=new RandomAccessFile("a.c","r");

 

long pos=raf.length();

 

int ch;

 

while((ch=fr.read())!=-1)

 

{

 

while(pos>0)

 

{

 

pos=pos-1;

 

raf.seek(pos);

 

byte b=raf.readByte();

 

System.out.print((char)b);

 

}

 

}

 

fr.close();

 

}

 

}

 

/*================output================

smj@smj-virtual-machine:~$ javac slip6_2.java

smj@smj-virtual-machine:~$ java slip6_2

 

}

;)a)tni(,"d% si edoc iicsa eht"(ftnirp

;)a&,"c%"(fnacs

;)"= rahc a retne"(ftnirp

;a rahc

{

)(niam diov

>h.oidts<edulcni#

 

//EDOC IICSA//smj@smj-virtual-machine:~$

*/

//slip 7_3//

 

import java.io.*;

interface shape

{

public void area();

}

 

class rectangle implements shape

{

int w,l,s;

rectangle(int w,int l,int s)

{

this.w=w;

this.l=l;

this.s=s;

}

public void area()

{

double a;

a=w*l;

System.out.println("the area of reactangl is = "+a);

}

}

 

class square extends rectangle implements shape

{

int s;

square(int w,int l,int s)

{

super(w,l,s);

}

public void area()

{

super.area();

double a;

a=s*s;

System.out.println("the area of square is = "+a);

}

}

 

class circle  implements shape

{

int r;

circle(int r)

{

this.r=r;

}

public void area()

{

double a;

a=3.14*r*r;

System.out.println("the area of circle = "+a);

}

}

 

class slip7_3

{

public static void main(String ar[])throws IOException

{

int ra,le,wd,si;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

 

System.out.print("enter a width of rectangel = ");

wd=Integer.parseInt(br.readLine());

System.out.print("enter a length of rectangel = ");

le=Integer.parseInt(br.readLine());

 

System.out.println();

 

System.out.print("enter side of square = ");

si=Integer.parseInt(br.readLine());

square o2=new square(wd,le,si);

o2.area();

 

System.out.println();

System.out.print("enter radius of circle = ");

ra=Integer.parseInt(br.readLine());

circle o3=new circle(ra);

o2.area();

System.out.println();

}

}

 

 

/*=================output===================

smj@smj-virtual-machine:~$ javac slip7_3.java

smj@smj-virtual-machine:~$ java slip7_3

enter a width of rectangel = 3

enter a length of rectangel = 4

 

enter side of square = 5

the area of reactangl is = 12.0

the area of square is = 0.0

 

enter radius of circle = 7

the area of reactangl is = 12.0

the area of square is = 0.0

smj@smj-virtual-machine:~$

*/

//========slip 6_3======//

 

import java.io.*;

class Insfficiantbalances extends Exception

{

 

}

 

class savingAccount

{

int acc_no;

double balances;

String name;

savingAccount(double balances,int acc_no,String name)

{

this.balances=balances;

this.acc_no=acc_no;

this.name=name;

System.out.println();

 

System.out.println("the account name is = "+name);

System.out.println("the account number is = "+acc_no);

System.out.println("the account balances is = "+balances);

}

 

void withdraw()throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

 

System.out.print("enter a amount ot be withdraw = ");

double w_amt=Double.parseDouble(br.readLine());

 

try

{

if(w_amt>(balances-500))

{

throw new Insfficiantbalances();

}

else

{

balances=balances-w_amt;

System.out.println("collect cash");

}

}

catch(Insfficiantbalances e)

{

System.out.println("insufficient balances");

}

}

 

 

void diposit() throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("enter diposit amount = ");

double d_amt=Double.parseDouble(br.readLine());

balances=balances+d_amt;

System.out.println("the total amount is = "+balances);

}

 

void view_balances()

{

System.out.println("present balances is = "+balances);

}

}

 

class slip2

{

public static void main(String ar[])throws IOException

{

int ch;

int c;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

savingAccount o1=new savingAccount(5000,1123415,"saving account");

System.out.println();

do

{

System.out.println("1:withdraw money\n2:diposit\n3:view balances\n\n");

System.out.print("enter your choices = ");

ch=Integer.parseInt(br.readLine());

switch(ch)

{

case 1: o1.withdraw();

break;

case 2: o1.diposit();

break;

case 3: o1.view_balances();

break;

default:System.out.println("invalid case");

}

System.out.println();

System.out.println("you want continue or not (1/0)");

c=Integer.parseInt(br.readLine());

if(c==0)

break;

 

}while(true);

}

}

 

/*=============output=============

smj@smj-virtual-machine:~$ javac slip2.java

smj@smj-virtual-machine:~$ java slip2

 

the account name is = saving account

the account number is = 1123415

the account balances is = 5000.0

 

1:withdraw money

2:diposit

3:view balances

 

 

enter your choices = 1

enter a amount ot be withdraw = 5000

insufficient balances

 

you want continue or not (1/0)

1

1:withdraw money

2:diposit

3:view balances

 

 

enter your choices = 3

present balances is = 5000.0

 

you want continue or not (1/0)

1

1:withdraw money

2:diposit

3:view balances

 

 

enter your choices = 1

enter a amount ot be withdraw = 4000

collect cash

 

you want continue or not (1/0)

1

1:withdraw money

2:diposit

3:view balances

 

 

enter your choices = 1500

invalid case

 

you want continue or not (1/0)

1

1:withdraw money

2:diposit

3:view balances

 

 

enter your choices = 3

present balances is = 1000.0

 

you want continue or not (1/0)

1

1:withdraw money

2:diposit

3:view balances

 

 

enter your choices = 1 

enter a amount ot be withdraw = 600

insufficient balances

 

you want continue or not (1/0)

1

1:withdraw money

2:diposit

3:view balances

 

 

enter your choices = 3

present balances is = 1000.0

you want continue or not (1/0)

1

1:withdraw money

2:diposit

3:view balances

enter your choices = 1 

enter a amount ot be withdraw = 500

collect cash

you want continue or not (1/0)

1

1:withdraw money

2:diposit

3:view balances

enter your choices = 3

present balances is = 500.0

you want continue or not (1/0)

*/

//slip 7_3//

 

import java.io.*;

interface shape

{

public void area();

}

 

class rectangle implements shape

{

int w,l,s;

rectangle(int w,int l,int s)

{

this.w=w;

this.l=l;

this.s=s;

}

public void area()

{

double a;

a=w*l;

System.out.println("the area of reactangl is = "+a);

}

}

 

class square extends rectangle implements shape

{

int s;

square(int w,int l,int s)

{

super(w,l,s);

}

public void area()

{

super.area();

double a;

a=s*s;

System.out.println("the area of square is = "+a);

}

}

 

class circle  implements shape

{

int r;

circle(int r)

{

this.r=r;

}

public void area()

{

double a;

a=3.14*r*r;

System.out.println("the area of circle = "+a);

}

}

 

class slip7_3

{

public static void main(String ar[])throws IOException

{

int ra,le,wd,si;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

 

System.out.print("enter a width of rectangel = ");

wd=Integer.parseInt(br.readLine());

System.out.print("enter a length of rectangel = ");

le=Integer.parseInt(br.readLine());

 

System.out.println();

 

System.out.print("enter side of square = ");

si=Integer.parseInt(br.readLine());

square o2=new square(wd,le,si);

o2.area();

 

System.out.println();

System.out.print("enter radius of circle = ");

ra=Integer.parseInt(br.readLine());

circle o3=new circle(ra);

o2.area();

System.out.println();

}

}

 

 

/*=================output===================

smj@smj-virtual-machine:~$ javac slip7_3.java

smj@smj-virtual-machine:~$ java slip7_3

enter a width of rectangel = 3

enter a length of rectangel = 4

 

enter side of square = 5

the area of reactangl is = 12.0

the area of square is = 0.0

 

enter radius of circle = 7

the area of reactangl is = 12.0

the area of square is = 0.0

smj@smj-virtual-machine:~$

*/

//======slip 7_1=======//

 

import java.io.*;

class slip7_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int i,n;

int a[]=new int[12];

int min;

System.out.print("enter a no you want = ");

n=Integer.parseInt(br.readLine());

for(i=0;i<n;i++)

{

System.out.print("enter a no = ");

a[i]=Integer.parseInt(br.readLine());

}

min=a[0];

for(i=0;i<n;i++)

{

if(min>a[i])

{

min=a[i];

}

}

System.out.println("The samll no is  = "+min);

 

}

}

 

/*==================output=============

smj@smj-virtual-machine:~$ javac slip7_1.java

smj@smj-virtual-machine:~$ java slip7_1

enter a no you want = 3

enter a no = 12

enter a no = 4

enter a no = 56

The samll no is  = 4

smj@smj-virtual-machine:~$

*/

//slip 8_1//

 

import java.io.*;

class slip8_1

{

public static void main(String arg[])throws IOException

{

 

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int no,rem,rev=0;

System.out.printf("enter a no = ");

no=Integer.parseInt(br.readLine());

 

while(no!=0)

{

rem=no%10;

rev=rev*10+rem;

no=no/10;

}

System.out.println("The revers no is = "+rev);

}

}

 

/*===================output==============

smj@smj-virtual-machine:~$ javac slip8_1.java

smj@smj-virtual-machine:~$ java slip8_1

enter a no = 123

The revers no is = 321

smj@smj-virtual-machine:~$ */

//=======slip8_2=========//

 

 

import java.util.*;

 

import java.io.*;

 

class slip8_2

 

{

 

public static void main(String arg[])throws IOException

 

{

 

String name;

 

double salary;

 

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

 

Hashtable ht=new Hashtable();

 

String ch;

 

do

 

{

 

System.out.print("Enter a Emp name = ");

 

name=br.readLine();

 

System.out.print("Enter a Emp salary = ");

 

salary=Double.parseDouble(br.readLine());

 

ht.put(name,salary);

 

System.out.print("you want continue Y/N = ");

 

ch=br.readLine();

 

}

while(ch.equals("y"));

 

 

System.out.println("Emp name \t Salary");

 

Set s=ht.keySet();

 

Iterator it=s.iterator();

 

 

while(it.hasNext())

 

{

 

Object k=it.next();

 

Object v=ht.get(k);

 

System.out.println(k+"\t"+v);

 

}

 

System.out.print("Enter a name of spacific Emp = ");

 

String em=br.readLine();

 

if(ht.containsKey(em))

 

{

 

System.out.println("Emp salary is = "+salary);

 

}

 

else

 

{

 

System.out.println("Emp salary is not found");

 

}

 

}

 

}

 

 

/*=================== output==============

smj@smj-virtual-machine:~$ javac slip8_2.java

smj@smj-virtual-machine:~$ java slip8_2

Enter a Emp name = aaaa

Enter a Emp salary = 60000

you want continue Y/N = y

Enter a Emp name = bbbb

Enter a Emp salary = 70000

you want continue Y/N = n

Emp name  Salary

aaaa       60000.0

bbbb     70000.0

//====slip9_1===//

 

import java.io.*;

class slip9_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int a;

System.out.print("enter a table no you want = ");

a=Integer.parseInt(br.readLine());

int i;

for(i=1;i<=10;i++)

{

System.out.println(a+" * "+i+" ="+a*i);

}

}

}

 

/*===============output==============

smj@smj-virtual-machine:~$ javac slip9_1.java

smj@smj-virtual-machine:~$ java slip9_1

enter a table no you want = 2

2 * 1 =2

2 * 2 =4

2 * 3 =6

2 * 4 =8

2 * 5 =10

2 * 6 =12

2 * 7 =14

2 * 8 =16

2 * 9 =18

2 * 10 =20

smj@smj-virtual-machine:~$

*/

//slip 9_2//

 

import java.io.*;

class MyNumber

{

public int no;

public MyNumber()

{

no=0;

}

public MyNumber(int no)

{

this.no=no;

}

public void isNegative()

{

if(no<0)

{

System.out.println("no is Negative");

}

}

 

public void isPositive()

{

if(no>0)

{

System.out.println("no is Positive");

}

}

 

public void isOdd()

{

if(no%2!=0)

{

System.out.println("no is Odd");

}

}

 

public void isEven()

{

if(no%2==0)

{

System.out.println("no is Even");

}

}

}

 

class slip9_2

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int num;

System.out.print("Enter a no =");

num=Integer.parseInt(br.readLine());

MyNumber mn=new MyNumber(num);

mn.isNegative();

mn.isPositive();

mn.isOdd();

mn.isEven();

}

}

 

 

/*===================output==============

smj@smj-virtual-machine:~$ javac slip9_2.java

smj@smj-virtual-machine:~$ java slip9_2

Enter a no =4

no is Positive

no is Even

smj@smj-virtual-machine:~$ javac slip9_2.java

smj@smj-virtual-machine:~$ java slip9_2

Enter a no =1

no is Positive

no is Odd

smj@smj-virtual-machine:~$ javac slip9_2.java

smj@smj-virtual-machine:~$ java slip9_2

Enter a no =-10

no is Negative

no is Even

smj@smj-virtual-machine:~$ javac slip9_2.java

smj@smj-virtual-machine:~$ java slip9_2

Enter a no =11

no is Positive

no is Odd

smj@smj-virtual-machine:~$

*/

//========slip 12_1 =======//

 

import java.io.*;

class slip12_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int n1,n2,gcd=1,i;

System.out.print("Enter a n1 = ");

n1=Integer.parseInt(br.readLine());

 

System.out.print("Enter a n2 = ");

n2=Integer.parseInt(br.readLine());

 

for(i=1;i<=n1 && i<=n2;i++)

{

if(n1%i==0 && n2%i==0)

gcd=i;

}

System.out.println();

System.out.println("GCD of "+n1+" and "+n2+ " = "+gcd);

System.out.println();

}

}

 

/*===============output===================

smj@smj-virtual-machine:~$ javac slip12_1.java

smj@smj-virtual-machine:~$ java slip12_1

Enter a n1 = 24

Enter a n2 = 27

 

GCD of 24 and 27 = 3

 

smj@smj-virtual-machine:~$

smj@smj-virtual-machine:~$ javac slip12_1.java

smj@smj-virtual-machine:~$ java slip12_1

Enter a n1 = 212

Enter a n2 = 34

 

GCD of 212 and 34 = 2

*/

//========slip 12_3==========//

 

import java.io.*;

class emp

{

int id;

String name,dept;

double salary;

 

public emp()

{}

public emp(int id,String name,String dept,double salary)

{

this.id=id;

this.name=name;

this.dept=name;

this.salary=salary;

}

 

public void accept()throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter a Emp id = ");

id=Integer.parseInt(br.readLine());

 

System.out.print("Enter a Emp Name = ");

name=br.readLine();

 

System.out.print("Enter a Emp dept = ");

dept=br.readLine();

 

System.out.print("Enter a Emp salary = ");

salary=Double.parseDouble(br.readLine());

 

}

 

public void display()

{

System.out.println("The Emp id is = "+id);

System.out.println("The Emp Name is = "+name);

System.out.println("The Emp dept is = "+dept);

System.out.println("The Emp salary is = "+salary);

}

}

class Manager extends emp

{

double total_salary,bonus;

Manager()

{}

 

public Manager(int id,String name,String dept,double salary,double bonus)

{

super(id,name,dept,salary);

this.bonus=bonus;

}

public void accept()throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter a manager id = ");

id=Integer.parseInt(br.readLine());

 

System.out.print("Enter a manager Name = ");

name=br.readLine();

 

System.out.print("Enter a manager dept = ");

dept=br.readLine();

 

System.out.print("Enter a manager salary = ");

salary=Double.parseDouble(br.readLine());

 

System.out.print("Enter a manager bonus = ");

bonus=Double.parseDouble(br.readLine());

 

total_salary=salary+bonus;

}

 

public void display()

{

System.out.println();

System.out.println("The manager id is = "+id);

System.out.println("The manager Name is = "+name);

System.out.println("The manager dept is = "+dept);

System.out.println("The manager salary is = "+salary);

System.out.println("The manager total salary is = "+total_salary);

}

}

 

class slip12_3

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

double max_s=0;

int i,n;

emp o1=new emp();

o1.accept();

System.out.println();

o1.display();

System.out.println();

System.out.print("Enter a how many Manager = ");

n=Integer.parseInt(br.readLine());

Manager o2[]=new Manager[n];

System.out.println();

for(i=0;i<n;i++)

{

o2[i]=new Manager();

o2[i].accept();

}

System.out.println();

for(i=0;i<n;i++)

{

o2[i].display();

}

System.out.println();

max_s=o2[0].salary;

for(i=0;i<n;i++)

{

if(max_s<o2[i].salary)

{

max_s=o2[i].salary;

}

}

System.out.println();

for(i=0;i<n;i++)

{

if(max_s==o2[i].salary)

{

System.out.println("The Maximum salary of Manager is = "+o2[i].name);

System.out.println("The Maximum salary of Manager is = "+max_s);

}

}

System.out.println();

}

}

 

/*===================output================

smj@smj-virtual-machine:~$ javac slip12_3.java

smj@smj-virtual-machine:~$ java slip12_3

Enter a Emp id = 111

Enter a Emp Name = Ankit Pawar               

Enter a Emp dept = IT

Enter a Emp salary = 50000       

 

The Emp id is = 111

The Emp Name is = Ankit Pawar

The Emp dept is = IT

The Emp salary is = 50000.0

 

Enter a how many Manager = 2

 

Enter a manager id = 10101

Enter a manager Name = Jagdish Dusane

Enter a manager dept = IT Manager

Enter a manager salary = 10000

Enter a manager bonus = 50000

Enter a manager id = 20202

Enter a manager Name = Shubham Garad

Enter a manager dept = bankig

Enter a manager salary = 4000

Enter a manager bonus = 5000

 

 

The manager id is = 10101

The manager Name is = Jagdish Dusane

The manager dept is = IT Manager

The manager salary is = 10000.0

The manager total salary is = 60000.0

 

The manager id is = 20202

The manager Name is = Shubham Garad

The manager dept is = banking

The manager salary is = 4000.0

The manager total salary is = 9000.0

The Maximum salary of Manager is = Jagdish Dusane

The Maximum salary of Manager is = 10000.0

smj@smj-virtual-machine:~$

*/

//========slip 13_1=====//

 

import java.io.*;

class slip13_1

{

public static void main(String ar[])throws IOException

{

int no,fact=1,i;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter a no = ");

no=Integer.parseInt(br.readLine());

for(i=1;i<=no;i++)

{

fact=fact*i;

}

System.out.println("the Factorial of no is = "+fact);

}

/*==================Output=================

smj@smj-virtual-machine:~$ javac slip13_1.java

smj@smj-virtual-machine:~$ java slip13_1

Enter a no = 5

the Factorial of no is = 120

smj@smj-virtual-machine:~$

*/

//========slip 13_2========//

 

import java.io.*;

class slip13_2

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int a[]=new int[12];

int n,i,j;

System.out.print("enter a how many no you want = ");

n=Integer.parseInt(br.readLine());

for(i=0;i<n;i++)

{

System.out.print("enter a  no = ");

a[i]=Integer.parseInt(br.readLine());

}

 

System.out.println("Before sorting ");

for(i=0;i<n;i++)

{

System.out.println(a[i]);

}

for(i=0;i<n;i++)

{

for(j=0;j<n-i-1;j++)

{

if(a[j]<a[j+1])

{

int t;

t=a[j];

a[j]=a[j+1];

a[j+1]=t;

}

}

}

System.out.println();

 

System.out.println("After sorting ");

for(i=0;i<n;i++)

{

System.out.println(a[i]);

}

}

}

 

/*==================Output=================

smj@smj-virtual-machine:~$ javac slip13_2.java

smj@smj-virtual-machine:~$ java slip13_2

enter a how many no you want = 4

enter a  no = 12

enter a  no = 1

enter a  no = 32

enter a  no = 4

Before sorting

12

1

32

4

After sorting

32

12

4

1

smj@smj-virtual-machine:~$

*/

//slip 13_3//

 

import java.io.*;

class nozero extends Exception

{

 

}

 

class plogic

{

public void prime(int n)

{

int i,m=0,temp=0;

m=n/2;

if(n==0 || n==1)

{

System.out.println("is not prime no ");

}

else

{

for(i=2;i<=m;i++)

{

if(n%i==0)

{

System.out.println("no is not prime");

temp=1;

break;

}

}

if(temp==0)

{

System.out.println("no is prime");

 

}

}

}

}

 

 

class slip13_3

{

public static void main(String arg[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int no;

System.out.printf("enter a no = ");

no=Integer.parseInt(br.readLine());

 

try

{

if(no==0)

{

throw new nozero();

}

else

{

System.out.println("no is not zero");

}

}

catch(nozero e)

{

System.out.println("no is zero");

}

 

plogic o1=new plogic();

o1.prime(no);

 

}

}

 

/*===============output=====================

 

smj@smj-virtual-machine:~$ javac prime.java

smj@smj-virtual-machine:~$ java prime

enter a no = 1

no is not zero

is not prime no

smj@smj-virtual-machine:~$ javac prime.java

smj@smj-virtual-machine:~$ java prime

enter a no = 2

no is not zero

no is prime

smj@smj-virtual-machine:~$ javac prime.java

smj@smj-virtual-machine:~$ java prime

enter a no = 3

no is not zero

no is prime

smj@smj-virtual-machine:~$ javac prime.java

smj@smj-virtual-machine:~$ java prime

enter a no = 4

no is not zero

no is not prime

smj@smj-virtual-machine:~$*/

//====slip 14_1====//

 

import java.io.*;

class slip14_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int a=0,b=1,c,i,n;

System.out.print("Enter a no upto fibo series you want = ");

n=Integer.parseInt(br.readLine());

System.out.println();

System.out.println(a);

System.out.println(b);

for(i=0;i<n;i++)

{

c=a+b;

a=b;

b=c;

System.out.println(c);

}

 

}

}

 

/*===================output==============

smj@smj-virtual-machine:~$ javac slip14_1.java

smj@smj-virtual-machine:~$ java slip14_1

Enter a no upto fibo series you want = 10

 

0

1

1

2

3

5

8

13

21

34

55

89

smj@smj-virtual-machine:~$

*/

//=========slip 14_2 =======//

 

import java.io.*;

class slip14_2

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

String str;

char s;

int i;

int cn=0;

System.out.print("Enter a String = ");

str=br.readLine();

int count=str.length();

System.out.println("the count is = "+count);

System.out.print("Search a spacific char in the String = ");

s=(char)br.read();

 

for(i=0;i<count;i++)

{

if(s==str.charAt(i))

{

System.out.println();

cn++;

}

}

System.out.println();

System.out.println("char is same count = "+cn);

System.out.println();

}

}

 

/*smj@smj-virtual-machine:~$ javac an.java

smj@smj-virtual-machine:~$ java an

Enter a String = jagdish

the count is = 7

Search a spacific char in the String = j

char is same count = 1

smj@smj-virtual-machine:~$

*/

//=======slip 14_3 =========//

 

 

import java.awt.*;

 

import javax.swing.*;

 

public class slip14_3

 

{

 

JFrame f=new JFrame("Login window");

 

slip14_3()

 

{

 

JLabel l1=new JLabel("User Name");

 

JLabel l2=new JLabel("Password");

 

JTextField t1=new JTextField(20);

 

JTextField t2=new JPasswordField(20);

 

JButton login=new JButton("LOGIN");

 

JButton end=new JButton("REGISTER");

 

 

f.setLayout(new GridLayout(3,2));

 

f.add(l1);

f.add(t1);

f.add(l2);

 

f.add(t2);

f.add(login);

f.add(end);

f.setSize(400,150);

f.setVisible(true);

}

public static void main(String ar[])

{

slip14_3 a=new slip14_3();

}

}

//=======slip 15_1 ===========//

 

import java.io.*;

class slip15_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int a,b,c;

System.out.println("Enter a two no = ");

a=Integer.parseInt(br.readLine());

b=Integer.parseInt(br.readLine());

c=a+b;

System.out.println();

System.out.println("The addition is = "+c);

System.out.println();

}

}

 

/*===================output==================

smj@smj-virtual-machine:~$ javac slip15_1.java

smj@smj-virtual-machine:~$ java slip15_1

Enter a two no =

12

34

The addition is = 46

smj@smj-virtual-machine:~$

*/

//slip 15_2

 

import java.io.*;

import java.lang.Math;

abstract class shape

{

abstract void calc_area();

abstract void calc_volume();

}

 

class sphere extends shape

{

int radius;

double a;

public sphere(int radius)

{

this.radius=radius;

}

 

public void calc_area()

{

a=4*3.14*radius*radius;

System.out.println("\nThe Area of sphere is = "+a);

}

public void calc_volume()

{

double v;

v=4*3.14*radius*radius*radius;

System.out.println("\nThe volume of sphere is = "+v);

}

}

class Cone extends shape

{

public int hight;

public int radius;

public Cone(int hight,int radius)

{

this.hight=hight;

this.radius=radius;

}

 

public void calc_area()

{

double a;

a=3.14*radius*(radius+Math.sqrt(hight*hight+radius*radius));

System.out.println("\nThe Area of cone is = "+a);

}

public void calc_volume()

{

double v;

v=3.14*radius*radius*hight/3;

System.out.println("\nThe Volume of cone = "+v);

}

}

 

class slip15_2

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int r,l,h;

System.out.print("enter a radius of sphere = ");

r=Integer.parseInt(br.readLine());

sphere ob1=new sphere(r);

ob1.calc_area();

ob1.calc_volume();

 

System.out.print("enter a hight of cone = ");

h=Integer.parseInt(br.readLine());

 

System.out.print("enter a  radius of cone = ");

l=Integer.parseInt(br.readLine());

 

Cone ob2=new Cone(l,h);

ob2.calc_area();

ob2.calc_volume();

System.out.println();

}

}

 

/*==================output==================

smj@smj-virtual-machine:~$ javac slip15_2.java

smj@smj-virtual-machine:~$ java slip15_2

enter a radius of sphere = 4

The Area of sphere is = 200.96

The volume of sphere is = 803.84

enter a hight of cone = 2

enter a  radius of cone = 3

The Area of cone is = 35.20286200991386

The Volume of cone = 12.56

smj@smj-virtual-machine:~$

*/

//=====slip15_3========//

 

<html>

<body>

<applet code="slip15_3.java" width="300" height="300">

</applet>

</body>

</html>

//=====slip15_3========//

 

 

import java.applet.*;

 

import java.awt.*;

 

import java.awt.event.*;

 

public class slip15_3 extends Applet implements MouseListener

 

{

 

private int x,y=10;

 

private String s="";

 

public void init()

 

{

 

addMouseListener(this);

 

}

 

 

public void paint(Graphics g)

 

{

 

g.drawString(s+"at"+"("+x+","+y+")",50,50);

 

}

 

private void setValues(String event,int x,int y)

 

{

 

s=event;

 

this.x=x;

 

this.y=y;

 

repaint();

 

}

 

 

public void mouseMoved(MouseEvent e)

 

{

 

setValues("Moved",e.getX(),e.getY());

 

}

 

 

public void mouseClicked(MouseEvent e)

 

{

 

setValues("Clicked",e.getX(),e.getY());

 

}

 

 

public void mouseReleased(MouseEvent e)

 

{

 

setValues("Release",e.getX(),e.getY());

 

}

 

 

public void mousePressed(MouseEvent e)

 

{

 

setValues("Pressed",e.getX(),e.getY());

 

}

 

 

 

public void mouseEntered(MouseEvent e)

 

{

 

setValues("enter",e.getX(),e.getY());

 

}

 

 

public void mouseExited(MouseEvent e)

 

{

 

setValues("exit",e.getX(),e.getY());

}

}

/*=================OUTPUT=================

 

 javac slip15_3.java

smj@smj-virtual-machine:~$ appletviewer slip15_3.html

*/

//=======slip 16_1=====//

 

import java.io.*;

class slip16_1

{

public static void main(String ar[])throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int base,exp;

System.out.print("Enter a base no = ");

base=Integer.parseInt(br.readLine());

System.out.print("Enter a exponent no = ");

exp=Integer.parseInt(br.readLine());

 

int ans=power(base,exp);

System.out.println(base+" ^ "+exp+" = "+ans);

}

 

public static int power(int base,int exp)

{

if(exp!=0)

return(base*power(base,exp-1));

else

return 1;

}

}

/*=====================output================

smj@smj-virtual-machine:~$ javac slip16_1.java

smj@smj-virtual-machine:~$ java slip16_1

Enter a base no = 2

Enter a exponent no = 2

2 ^ 2 = 4

smj@smj-virtual-machine:~$

*/

//=======slip16_2=========//

 

import java.util.*;

import java.io.*;

class slip16_2

{

public static void main(String arg[])throws IOException

{

String name;

double salary;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

Hashtable ht=new Hashtable();

String ch;

do

{

System.out.print("Enter a Emp name = ");

name=br.readLine();

System.out.print("Enter a Emp salary = ");

salary=Double.parseDouble(br.readLine());

ht.put(name,salary);

System.out.print("you want continue Y/N = ");

ch=br.readLine();

}

while(ch.equals("y"));

 

System.out.println("Emp name \t Salary");

Set s=ht.keySet();

Iterator it=s.iterator();

 

while(it.hasNext())

{

Object k=it.next();

Object v=ht.get(k);

System.out.println(k+"\t"+v);

}

System.out.print("Enter a name of spacific Emp = ");

String em=br.readLine();

if(ht.containsKey(em))

{

System.out.println("Emp salary is = "+salary);

}

else

{

System.out.println("Emp salary is not found");

}

}

}

 

/*=================== output==============

smj@smj-virtual-machine:~$ javac slip16_2.java

Note: slip8_2.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

smj@smj-virtual-machine:~$ java slip16_2

Enter a Emp name = aaaa

Enter a Emp salary = 60000

you want continue Y/N = y

Enter a Emp name = bbbb

Enter a Emp salary = 70000

you want continue Y/N = n

Emp name           Salary

aaaa       60000.0

bbbb     70000.0

Enter a name of spacific Emp = bbbb

Emp salary is = 70000.0

smj@smj-virtual-machine:~$

*/

//=======slip16_3========//

 

 

import javax.swing.*;

 

import java.awt.*;

 

class slip16_3

 

{

 

public static void main(String arg[])

 

{

 

  JFrame f=new JFrame("Calculator");

 

JPanel p1=new JPanel();

 

JPanel p2=new JPanel();

 

JTextField tf=new JTextField();

 

 

JButton b1=new JButton("7");

 

 

JButton b2=new JButton("4");

 

JButton b3=new JButton("1");

 

 

JButton b4=new JButton("0");

 

 

JButton b5=new JButton("8");

 

 

 

JButton b6=new JButton("5");

 

JButton b7=new JButton("2");

 

JButton b8=new JButton(".");

 

 

JButton b9=new JButton("9");

JButton b10=new JButton("6");

JButton b11=new JButton("3");

JButton b12=new JButton("+");

JButton b13=new JButton("-");

JButton b14=new JButton("*");

JButton b15=new JButton("/");

JButton b16=new JButton("=");

p1.setLayout(new BorderLayout());

p2.setLayout(new GridLayout(4,4));

p1.add(tf,"North");

p2.add(b1);

p2.add(b2);

p2.add(b3);

p2.add(b4);

p2.add(b5);

p2.add(b6);

p2.add(b7);

p2.add(b8);

p2.add(b9);

p2.add(b10);

p2.add(b11);

p2.add(b12);

p2.add(b13);

p2.add(b14);

p2.add(b15);

p2.add(b16);

p1.add(p2);

f.add(p1);

f.setSize(500,300);

f.setVisible(true);

}

}

 

 

C language and C++ progaming