OOPS Lab
OOPS Lab
Output-
E'mol amount 1338. 2253
Puoqam b calculate the depaecition,
Popublie class Depse ciadion
publie stabic vaid main (Stingl arg)
float fc = 5000;
float sv = 200)
ploat s =5;
phoat dep - (fe- sv)/sy
System. out pintdn ('Depgeáaton "* dep);
Qulpuk
Debne aaion = 960.0
to cow et Fahenheit to Csius.
37
class calculaton f
Noid add (in a, int b);
imt c - atb;
Sytem.out.pruntln(te"Sum = "te):
Oubut:
Ente 1 rot addition
Entor 2 fox subbaction
Entor 3 pon mutiplicotion
Ent 4 for diviíon
Enter for emandeL
Cholse 4
Suotient -3.14351
5> Wue o constuucto9L in the
Cou cla given balow
that iritiaize the bsond doss pield th the sbung
Ford'.
bnand"Fond';
Output
The band mame o the caÚL is Ford
Systemovin-paittasing
stem pruirtln(Eroaing qua ");
Trionge
t. dotaw();
t.dora );
Squane
5. dow
S. AseO;
3
Ouput
Drawing a cicle
Exasing
Drouing a tiangle
Exasing biangle
Dxauing
Exasing
wite print the name of sudents
Student name s paMed
by crenting then the
object f Student clas,
while eteaing the mame shoul
mame hould be Unknown', Othewise
be ezual to the soing value passec.
Proa'
class student
Stbing mame
Student(S ibing )i
mame = n;
class B extends S
class RunbimaPlymohum
publie tatic void maln (stringl] y l
Test t = mew Test () ;
t. Ahow);
A a a: mew AO;
A a-hoo ():
b.show(
Output:
Fnom text class
From A class
From B clas
progom to maintain he opgicial dotabose
ing single inheütance. Supe elos is Employe that
condains rollouing into Emp- codo, Emp. Name ,Emp-Add,
Emp. PhNo, DA - 30% HRA -207. . Cneote 3 saodasse
Maaget, Typut and ogicet, aach clas hauing
thei basie amd DA, HRA nemain
Praa
class Employee i
int Emp Code;
ft Nama,
Emt- Name,
ind stung Emt
Stung Emp- Add;
Sing Emp_PhNo,
Aouble Basic
Apuble DA,
doulola HRA;
Employee (int Emp. Coda, Stbçng Emp.Name stsing
Emp-Add, sbing emp-Philo) i
ths.Emp-Code = Emp- Code :
this. Enp- Name - Emp- Name;
Add Emp-Add;
his.Emp-Add
PhNo Emp-hNo;
this. Bo/e 0. o)
this. DA 0.3;
this HRA = 0.2;
Void Cale- Sal()3
doulble Saauy - Basie +(Basie DA)+ (BasicY HRA):
Syatem.out println(Employee Code : "+ Emp- Code):
Syetem. oud pruntlm (Employee Name : "+ Emp- Nam);
Sytem.out pintln (Employee Addess : 4 Emp. Add);
Sytem.out pountln("Emplogee Phone No:'4Emp.PhNo);
System. out puntln(E Basic Payment :"+ Bosic):
System. out.println DA:+DAl00 +"z")
System. out pountln( HRA : "+ HRAB*100 t"%):
Syatem. out. printn"Total Salary :"+salooy):
Syotem. out.prünttn("
DA : 30.07
BHRA 20. 07%
Total solay : 34 500.o
DA: 30.0
HRA : 20.0/.
lay:
Total Salo 525 00.o
proqam toto ceate intenpace A. Tn this
intepace we hove methods - meth 1 and meth 2.
this noace in another class mamed My Clas.
Tmslement
1
2
1 Bina Seanch
clas BinaySemch i
pablie atatie void mam (stbing l] ang
inll a-2,5,7,9, 12,14,1 6,13,19, 20, 2b, 28j;
int taonact =16)
int lo = 0;
int hi - a.length -;
while (Io < hi)
int mid =(Lo+ti)/2:
== a[md ])
Sykem oat. prüntn (Toget is found t
"4 mid
index):
bcak;
else i (taget <a [mid]) {
Lo -mid +i;