hts.StevenWood.com

Labs 1

Home ] Up ] How to use Methods in Java ] Methods and Parameters in Java ] Creating User-Defined Methods ] Common Programming Errors ] Good Programming Practices ] Lab Exercises ] [ Labs 1 ] Labs 2 ] Rubric ][ Last Page ]

Defining Our Own Subroutines – Sample Lab Exercises

Write a programmer-defined subroutine for the following:

1.

Function CelsiusToFahrenheit (degrees as real) returns real

return ((degrees * (9 / 5)) + 32)

end Function

2.

Function FahrenheitToCelsius (degrees as real) returns real

return ((degrees - 32) * (5 / 9))

endFunction

3.

Function MilesToKms (miles as real) returns real

return (miles * 1.6)

end Function

4. 

Function KilobytesToBits (k as real) returns real

return(k * 1024 * 8)

end Function

 Create a bank balance program, based on the algorithm created earlier in this activity, defining programmer-defined subroutines as appropriate.

 

Source: Public and Catholic District School Board Writing Partnership Course Profile: Computer and Information Science, Grade 11, University/College Preparation ICS3U, Queen’s Printer for Ontario, 2001, adapted.

Home ] Up ] How to use Methods in Java ] Methods and Parameters in Java ] Creating User-Defined Methods ] Common Programming Errors ] Good Programming Practices ] Lab Exercises ] [ Labs 1 ] Labs 2 ] Rubric ][Last Page]
All material on this site is copyright © 1997- by Steven Wood or as credited. All right reserved. Use of this site indicates you agreement with the  terms of use.
Send comments or questions to about this page.
Every attempt has been made to credit work under copyright. If there are any claims that copyright has been missed please contact the .
+SDG+