Java Reference
In-Depth Information
System.out.print("Enter 1 or 2: ");
num = console.nextInt();
System.out.println();
System.out.print("Take ");
if (num == 1)
func1();
else if (num == 2)
func2();
else
System.out.println("Invalid input. "
+ "You must enter a 1 or 2");
}
public static void func1()
{
System.out.println("Programming I.");
}
public static void func2()
{
7
System.out.println("Programming II.");
}
}
a. What is the output if the input is 1 ?
b. What is the output if the input is 2 ?
c. What is the output if the input is 3 ?
d. What is the output if the input is -1 ?
28. Consider the following program:
import java.util.*;
public class Chapter7Ex28
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
double one, two;
System.out.print("Enter two numbers: ");
one = console.nextDouble();
two = console.nextDouble();
System.out.println();
traceMe(one, two);
traceMe(two, one);
}
Search WWH ::




Custom Search