0% found this document useful (0 votes)
33 views7 pages

Java Example

1. The document describes creating a ChooseManager class that prompts the user to select a private or corporate event type and displays the corresponding manager. 2. It then provides code snippets to create an Event class to store data about planned events, including event type, manager name, and hourly rate. 3. The final section indicates the program will next write an application that uses the Event class to make decisions based on the selected event type.

Uploaded by

MuhammadRamadan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views7 pages

Java Example

1. The document describes creating a ChooseManager class that prompts the user to select a private or corporate event type and displays the corresponding manager. 2. It then provides code snippets to create an Event class to store data about planned events, including event type, manager name, and hourly rate. 3. The final section indicates the program will next write an application that uses the Event class to make decisions based on the selected event type.

Uploaded by

MuhammadRamadan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Y OU D O I T

US I N G A N i f

s e

dl e r s I n c o o r a t e d t h a t
de t
m in e s w h i c h e m p l o y e e w i l l b e a s s ign e d t o m a n a g e a c l i e n e s s c h e du l e d e v e n t T o b e g i n y o u
b t t he e v e n t t y p e a n d t he n t h e p r o gr a m w il l
i
w i ll p r o m
p t t he u se r t o a n sw e r a qu e st o n a o u
di s p l a y t h e n a n e o f t h e m a n a g e r w h o h a n d l e s s u c h e v e n t s T h e r e a r e t w o e v e n t t y p e s : p r i v a t e
d l e d by C a r m e n L i n d s e y
t h
I e v e n t s h a n dl e d b y D u s t i n B r i t t , a n d c o 1p o r a t e e v e n s , a n
I n t his

se c ti o n

yo u

ill s t a r t

w r

it in g

p r o gr a m fo r E v

en t

an

To

it e

wr

1 O en
p
Ch o

T he
iw

Pu

pr

tex t

a n ew

o s e

Ma

n a

c l as s w

t ha t c ho

ge

ill

fi le

Yo u

c o n t ain a

o r

tav

bl i

a s s

Pu b l i

t i l

d t he n

an

be t w

o se s

en

een

tw

fi r s t l i n

t e r t he

er s:

es o

ill im po r t t he Sc a n n e r c las s
m a i n 0 m e t h o d t h a t p e r fo r m

Sc

Ch o

o 8 e

t i c

v o

a n n e r

so

g
<

i Ld

Scanned by CamScanner

ma

(S t

g []

a r

de

t o c r e at e a c la ss n a m e d

t hat y o u c a n u se

s a ll t h e w

B* a n a g e

co

gs )

k e y bo a r d i n p u t
o r k o f the c lass:

On

to e

u se r

m an

St

f i
f i

e s

l i c a t i o n w i l l u s e YO
i a
l e : ; 1110 c o n s t a n t : ; t h s p p
o r t he e v e n t t y pe s a n d t he n a
T y p e T he v a lu e s
r e d a s s y m bo lic c o n s t a n t s ; t
v e n ts ar e sto

Cle c l a i

e t i l e v a r i a tl

in te r e r e v e n t
a g e > s fo r
p r iv a t e a n d c o r p a r a t e e
a g e r w ill be a s s i n e d t o t h e c h o s
g

m an

lin

n ew

n te r a n

e v e n

t Ty p e ;

n a

PR I V A T E

n a

C OR P OR A T E

COD E

f na1

St

PR I

AN A GE R

f i

s t

C OR P

M A N A GE R

n a

fin

Ma

o s e n

n a

ge

str

e r

n a

in g:

2 ;

t :

"

Du

"

Ca

r m e n

Br i t A

L i n d

s e

"

h e in p u t de v ic e t h e n a dd t h e c o de t h a t p r o m p t s t h e u s e r
the ev en t t
y p e b e in g s c h e du le d a n d a c c e p t t he r e s p o n s e :

to en ter a 1or 2

e t

in g

o n

Sc

a n n e r

Sy

t e

Sy

t e

Ou

Ou

t Tw

e v e n

U
c

: f

'

t Typ

o s e n

o s e n

Sc

n e w

t l

n
"

C OD E
u

"

"

N e x

t l

c o r

e v e n

o r a

a r e

COD E

PR I V A T E

"

to c ho o se the n a m e o

fo l l o w

s c

o u

"

o r

v a

l i

g?

"

"

:
+

f the

m an a

ge r t o be

a s s ig n e d

t o t he

s:

C OD E

Ma

n a

e r

P R I \ L M AN A GE R ;

Ma

n a

e r

C OR P

de

an

ho

Sy

Ou

Ou

e m

e na

o s e n

sen c o
r

Ma n

T yp e t h e t w

t 1n

t 1n

e r

o c lo s in

(
(

M A N A GE R ;

c o r r e spo n

"

Yo u

e n

e r e

"

Ma n a g e

din g

m a n a ge r s n a m e :

"

en ter s

Co

1anaf

1 fo

m m an

e 1

2 fo

r a co r

cu r

ly b r a c e s

p r iv a t e

r a

d Pro

o 1

r ate ev en

po

d t he

to en

t Fo

cor rec

r ex am

ev en t

e v e n

iLl l

"

m a

'

"

m et

ho d

. :le

' "

t m an a er w
g

p l e F ig u
,

re

an

d t he
an

Ch

r u n

o o s e

Ma

n a

lass
ge r c

t h e p r o gr a n r

h e n y o u c h o o s e 1 f o r a p r iv a t e
5 2 3 s h o w s t h e o u t u t w h e n t he u st r
p

e u e n

\ Ji

l l

D"

he

1n 1
Fi a u r e 5 23 Ou t p u t

t lri

t Typ

e v e n

le c t s t h e

ev en t o r

'

t h i

o r

& x : S W. c
B

e m

PR I V A TE

o r
n

st at e m e n t

( Sy

t y 0 e

e r
"

a n n e r

Wn a t

s t r in g, a s

e r

S e

D isp lay t h e

Sy

s e
c

v e n

n a

Ma

o s e n

(e

: f

se an

de pe r i

C OR P OR A T E

C OD E

Ma

e n

"

w
r

%I t
.

9
o f t he C h o o s e M a

Scanned by CamScanner

n a

ge

a p p l i c a t io
n a ft e r
Us e r e n t
e rs

::

A
:

8 Re r u

t he Ch

s e le c t e d

Ma

o o s e

is C a r m

n a

pr o gr a m

e r

L in d s e y be c a u

en

en

in

te r an

an

s av e t he

he n

e r r o r m e s s a ge w
r

l id it e m

v a

t h e p r o g a m t e s t s o

se

M o d i fj , t h e p r o g r a m t o d i s p l a y a n
Re n a m e t he c la s s Ch o o s e M a n a g e

an

fi l e

l y fo

su c

as

r an e n te re

3 T he

v a u e o

t h e e n t e r e d v a lu e

as

c ho

o se

an a

m a n a ge r

is

n o

g e r 2j

f 1or

n o

t 1

t I or 2

av a

CR EA T I N G A N E v e n t C L A S S T O U S E
I N A D E C I S I O N M A K I N G A P P L I CA T I O N
i ll

c la s s

T he

c la s s w

d by E v e n t H a n d l e r s I n c o r p o r a t e d
t o s t o r e d a t a a b o u t a p l a n n e d e v e n t E a c h E v e n t o bj e c t i n c l u d e s t h r e e d a t a fi e l d s : t h e t y p e o f
e v e n t t h e n a m e o f t h e m a n a g e r fo r t h e e v e n t a n d t h e h o u r l
y r a t e c h a r g e d fo r h a n d l i n g t h e
e v e n t T he E v e n t c la s s a lso c o n t a in s a
g e t a n d s e t m e t h o d f o r e a c h fi e l d
Nex t yo

u w

c r e ate an Ev e n t

To

t e the Ev

Ope n

fo

a s s

v a

dat a

Ev

t yp e o f Ev

v a

t e

v a

s t

e t

m e

ee

bl i

r e

u r n

b l i

r e

u r n

St

u r n

b l

r a

m a n a

t ho

ge t Typ

c la s s

h e a de r fo r t h e

Ev

ds;

ge

e ac

pub l i

b l

r a

e n

ge t Ra t

re

turn s o

n e o

f t h e d a t a fie ld s i n t h e

e ;

g e t Ma

j Ln g

n a

ge

(
r e

m a n a

ge

)
3 A ls o

a dd

pub l i

t hr e e
: d

v o

t ype o f Ev e

Pu b l i

: d

v o

s e
s e

s e

t m e tho

t Typ

ds ;

{:

e ac

(d o u b l

se t s a s in

e v e n

t Typ

g l e d a t a f i e ld :

t Ty p e ;

e v e n

t Ra t

e v e n

t Ra t

(
r a

Pu b l i

t e

ma n a

e v e n

v o

i d

ge

s e

t Ra t e ;

t Ma

m a n a

n a

d by

t y p e o f Ev

o u

fo l lo w

e ;

)
u

t c la ss,

t ;

e n

e n

e n

+n t
o u

d ty p e t he
fi e l d s :

an

Cr e a te t hr

fi l e

t he t hr e e

b l i

t c la s s :

e n

tex t

a n ew

t io n s

u se

cr ea

i ll be

(S t

Na

m e ;

ge

e r

Scanned by CamScanner

i Ln g

m a n a

ge

Na

m e

Ev

e n

t c la ss :

d ec l a

T yp e t he

Sa v

t he

lo s in g

file

Ev

as

l y b r a c e fo

cu r

en

t he c la ss

t h e n c o m p ile t h e

file

an

c o r rect an

er r o r s

W R I T I N G A N A P P L I CA T I O N T H A T U S E S
T H E E v e n L CLA SS
N

that yo u

ow

t io n

Yo

the Ev

pt the

c las s,

an Ev e n t

fo r

u se r

o n the se le c t e

based

e cr e ate

ill p r o

u w

e n

h av

an ev e n

yo u

t typ e ,

d t y p e P r iv

$ 4 ;: 9 9 p e r h o u r C o r p o r a t e e v e n t s a r e
E v e n t s h e l d by n o n p r o fi t o r g a n i z a t i o n
h o u r A f t e r t h e u se r se le c t s an e v e n t t

ppr
o

p r ia t e

te

cr e a

Ope n
Cr
i

v e

5a

v a

a s s

b l i

1n p o r

b l i

d by C a r m
a n a ge d by

s ar e m

ill in st a n t i a t e

a ppl

e c

ge r a n d a
B r it t a n d

r ate

fo r

Co s t
d by D u s t i n
d c o s t $7 5 9 9 p e r h o u r
e n L in ds e y a n
4
R o b i n A r m e n e t t i a n d c o s t $ 0 9 9 pe r

m a n a ge

Cr

the Ev

u se s

Ev

an

e n

c o n t a in

bje c t

in g

t c la ss:

e n

d t y p e t h e fo l l o w i n g

t e x t e d it o r a n

the

be gin

to

c la ss :

t i l

hat

fi l e i n y o u
n t o b j e c t

e a

p p li c a t io

a n ew

a m an a

dat a

ev e n t

an

both

se le c t

d then

an

a t e e v e n t s a r e m a n a ge

ype yo u

t ob
cre ate a Cr e a t e Ev e n

ill

Sc
t

e a

a n n e r

t ob

v e n

e c

l
p

t i c

i d

v o

m a

g []

a r

l
2

A dd
i

St

f i

an

t Typ

c o n st an t s th at w

o s e n

Ma

n a

ge

b l

o s e n

Ra t e

1e dEv

' "

'

Ev

s c

n a

PR I VA TE

C OR P OR A T E

C OD E

2 :

N ON P R O F I T

C OD E

3 ;

n a

f i

n a

+n t

f i

n a

St

n a

f i Ln

e n

n e w

C OD E

PR I VA T E

B N A G E R

St

COR P

s t

N ON P R O F I T

f i

n a

o u

b l

PR I V A T E

f i

n a

o u

b l

C OR P

do

b l

N ON P R O F I T

e a n

RA T E

75

e c lar e a Sc a n n e r

bj e c t

to

be

n e w

Sc

a n n e r

rea

Sc

d it in

Sy

s t

e m

e m

c0

nput

e v e n

Ou

o u

x :r
f

am

as

fo ll o w

s:

t r

Du s t i

"

L i n d s

r m e n

Ro b i n

i t c
e

5r

"

t t i

r m e n e

"

99 ;
40

99 ;

u e ;

u se

d fo r i n p u

t , p r o m pt t he u se r

nd
a n e v e n t t ype , a

fo r

a n n e r

Sy

gr

99 ;

RAT E

Ca

47

Go

c e

"

GE R

"

RA TE

e n

o o

the pr o

1 ;

B N A G E R

f j Ln

d in

0 ;

u se

e n

f i

ill b e

e :

f i

iable s

e v e n

o u

Ev

v ar

o r

t Ty p

n o n

Scanned by CamScanner

n
n

t 1n

( En
"

r o

f iLt

"

Wh
t

t yp
"

e r
"

f
"

N e x

t l

(Sy

c o r

t e

e v e n

PR I V A T E

o r

o r a

t e

a r e

C OD E
,

O r

i ro
"

+
"

s c

o r

h
p

e
r

d
i

1 i Ln g ?

v a

N ON P R OF I T

"

C ODE

;
+

"

Scanned by CamScanner

Scanned by CamScanner

Scanned by CamScanner

You might also like