// Copyright MageLang Institute; // Version $Id: //depot/main/src/edu/modules/JavaIntro2/magercises/Methodcall/Solution/Methodcall.java#2 $ public class Methodcall { public static void main(String[] args) { new Methodcall().start(); // students: ignore this } public void start() { // a test harness for two methods // #START_PASTE // // #END_PASTE // #START_CUT sayHello(); int a = addTwo(3); System.out.println("addTwo(3) is "+a); int b = addTwo(19); System.out.println("addTwo(19) is "+b); // #END_CUT } // #START_PASTE // Define method sayHello with no arguments and no return value // Make it print "Hello". // #END_PASTE // #START_CUT public void sayHello() { System.out.println("Hello"); } // #END_CUT // #START_PASTE // Define method addTwo with an int parameter and int return type // Make it add 2 to the parameter and return it. // #END_PASTE // #START_CUT public int addTwo(int i) { return i+2; } // #END_CUT }