/** * CS7 * This program demonstrates the use of a method. It converts numbers * to metric, Bob and Doug MacKenzie style, which is to say it is not * an accurate way. But still, it serves our purposes. * */ import tio.*; // use the package tio class BobAndDoug { public static void main (String[] args) { int value, answer; System.out.print("Enter a value you hoser: "); value = Console.in.readInt(); // this calls the method, stores the result in answer answer = calcBD(value); System.out.print(value + " in metric is " + answer + ", eh. "); System.out.println("Take off!"); } // These are javadoc comments. See p.131 in JBD. /** * Convert a number to metric, Bob and Doug style. This is a totally * bogus method. * * @param n The number being converted. * @return the number after being doubled and increased by 30. */ static int calcBD(int n) { return (n*2 + 30); } } /* SAMPLE OUTPUT: (6) unixs1 $ java BobAndDoug Enter a value you hoser: 14 14 in metric is 58, eh. Take off! (7) unixs1 $ */