OPENING LINE:
Howard Roark laughed [The
Fountainhead, Ayn Rand]
HAVE READ:
KNOW:
BE ABLE TO:
package nov03; public class AttemptSwap { /** Incorrect method to swap variable values. */ public static void swap (int x, int y) { int t = x; x = y; y = t; } /** Incorrect program to show how to swap variable values. */ public static void main (String []args) { // INPUT int a = 5; int b = 7; System.out.println (a); System.out.println (b); // try to swap values (INCORRECT) swap (a,b); System.out.println (a); System.out.println (b); } } |
DAILY QUESTION:
public static String evaluate(int
x) { if (x < 10) { return "low"; } } |
Sample Exam Question:
Write a program where the user types in on a single line a positive number n greater than zero, then types in n numbers separated by spaces followed by pressing Enter. Then output, one per line, each number that had been typed in which was less than 50. In your solution, your main method must be the following (so you must provide the two missing functions).
package nov03; import java.util.Scanner; public class SampleQuestion { /** Helper methods will appear here. */ /** Incorrect program to show how to swap variable values. */ public static void main (String []args) { Scanner sc = new Scanner(System.in); int nums[] = readArray (sc); outputLessThan50(nums); } } |