Lect 3.2 Scheme_examples - public class Imperativecfw just...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Imperative { // just a program name static int area = 0 ; // global height=4 static int result = 0 ; public static void calAreaProc(int length, int width) { area = length * width ; length =3 width=2 } public static void sumProc(int val1, int val2) { result = val1 + val2 ; } public static void displayResultProc(String str) { System.out.println(str + result) ; } public static void main(String[] args) { calAreaProc(2,3) ; sumProc(result, area * 2) ; // side effect calAreaProc(4,3) ; sumProc(result area * 2) ; sumProc(result, area 2) ; calAreaProc(4,2) ; sumProc(result, area * 2) ; displayResultProc("The total surface area of cubiod is "); } } 57
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon