Professional Documents
Culture Documents
CP2 Assignment
CP2 Assignment
CP2 Assignment
STi Vyshnav
21STUCHHO1OHI12
HSk uses te enter age, Gen des (M ol) matial Status Cyo
their plate o
and then
uxing
Aing tollowinq u l s print
Seuice in wban
employee is Jemale, then she wilu wok
enly
aLas
male. and is in bebween 20 to40
iemployee a a aqe
then he may wctk in anyusheie betwe en uoto 60
i male and age i in
6tmployec Only
uban auas
will wolk in
then he prird "ERROR"
should prind
And any othes input of age
d)
ProgYam
impovtjava. util Scanner;
class Wok
static
void
main ( Shing[] asgs
public
ScanntiCSystem in);
ntus
Scannes in
=
age");
println ("EnteY
System out d
in.next Int ();
int age
System.out
=
Ave you
mauied ? V/):
Syskm.Ot printtn
mauied in next().chaiAt(o)
fnt
Sex =='F)
it (Se M)
it (Cage>-20) 44(age< uo)
cusie eut printnMou may weik anjushere"
else 4 (Cage >=uo) à& (agee6o))
wban aleas .
Systern.eut.println (You will weik enly in
else
Output
Enter age: 50
Enter Sex:M/FF
Are yeu maied?: V/N;N
You wil weik Only in wban aiea
Next Page
rogmam
inpelt java. util.
class Speed
Output-
150
Poinh 6
License Suspendled
Wrtte a prCasam by Cieating an. 'Employee' clats bavíng.
this. Salay e
Salay,
this. no-othous =Ho_of-hoUs;
Votd addSal()
t CSalaaut 2 Soo)
Salay+ lo
Votd addwok )
tt (no-oB_houu>6)
Salay +=S
Void printSalay)
oB the emplDyee=+Salany"
Systen out príntln "Anal Salany
Scannei SC =
Scannet (Systerm-in);
neuo
Output-
Entey the Salauy of Ennployec: ho0
Kogram
public class SaMple
cha ch name-chaiAt(i);
HCch1-)
$1 S1+ch;
elue
printtn
System.Out p
system.out (characker. to Uppekdase
chaAA(o).
) =
1 "
Stting sa
fot(int jeD; j< 61. length (): j++)
if Cj--o)
SR= S2 + Chaiact.toUppexCase (S1-chasAt (o)
else
Sa- $2+ ChajactAtolowenCase (s1.chaiAtG);
Output:- 1
Contain
desiqned as qiven beloue. I
aTwO tutance vatablw xCint) and y Cind)
b)o"ne-aqument" CengtiuCto that Constucts a point atl
dd Cosltucio that CBnstiuct a
point with the
X Qnd y Co-oldinatts qive
d)A te Stking C) mcthod that ittuuw
o the instance in a
the Aoimat "Cxyp Stinq deiciphi
deiciptin
) AWEthod Caled
A talled distänce
distance Cd
1Sem his point
AStande em (tvd x,k, int
we. y)
u) ahat
-to
ansther
ansther pout thot ebuuns
Aetuns the
(-oidinatis
potutt at the
the Code
the classo given
giwen pyp
hite
class MyPbintt
int X,
MyPoiut ()
y:D
MyPoint Cint x, fnt )
thi's.X= X
his.y = 4
Void tostung C)
yStem-ouctp r i r t l n ( " + x + " + y + " ) " ) ;
int y1)
distance (int x1,
Void
int xdi X-x1;
-y1;
int ydtb =
"Math.sqat((x-x1)'(x-x1)+(y-v1)
("distance:
Systerm out príntln (4-v1)
Output
distance: 8.6023