FIT100 FIT100 FIT100
Concepts of Algorithmic Thinking
Functions and Methods: Functions and Methods:
Good Things Come in Small Packages
D.A. Cle me nts
Functions and Methods: Functions and Methods: Good Things Come in - - PowerPoint PPT Presentation
FIT100 FIT100 FIT100 Concepts of Algorithmic Thinking Functions and Methods: Functions and Methods: Good Things Come in Small Packages D.A. Cle me nts Functions FIT100 FIT100 FIT100 A func tio n is a pa c ka g e fo r a n a lg o
D.A. Cle me nts
c o mpute o n
f mo re tha n o ne , the y a re se pa ra te d b y c o mma s
func tion c onve rtC2F ( te mpInC ) { <sta te me nt list> }
l
la ng ua g e
sta te me nt: re turn <e xpre ssio n> p
func tio n c o nve rtC2F ( te mpI nC ) { re turn 9 0 / 5 0 * te mpI nC + 32; re turn 9.0 / 5.0 * te mpI nC + 32; }
W it th f ti ’ t th i t l (
t ) ∗ Write the func tio n’ s na me , put the input va lue s (argume nts)
in the pa re nthe se s c o nve rtC2F ( 38 ); ( );
F
F
(slide 10) (slide 10)
F
p () func tio n
t c o uld te ll the b ro wse r to put so me te xt b a c k in the file , a s in do c ume nt.write ()
numb e rs tha t pa sse s the sta tistic a l te sts fo r ra ndo mne ss
f nc tio n flipT e t() { func tio n flipT e xt() { if ( c o inF lip() == 0 )
pro b le ms p
Built-in Ja va Sc ript func tio ns