BPJ Quiz 07-09
-
Write a code that will create a
Scanner
calledm
that you can use to read keyboard input. -
Use the same Scanner to get a single
int
that a person types and store it in a variable calledn
. -
Use the same Scanner above to get a single word (String) and store it in a variable called
w
. -
Write in words the circumstances under which the function
f
below returns true.public static boolean f (boolean a, boolean b, int c) { return a && !b || b && c>10; }
-
The function
g
gives the table of values below.x y g(x,y) true false true false true false false false true true true false The function definition is missing the remainder of one line that will cause it to give the outputs listed in the table. Complete just that one line.
public static boolean g(boolean x, boolean y) { boolean answer = /* WHAT GOES HERE? */ return answer; }
-
Write a program to ask the human for an integer. Create an answer variable
String ans
. The answer should be “GOOD” if the number is divisible by 21, otherwise “OK” if the number is divisible by 7, otherwise “MEH”. The answer variable is a required part of your response.public class Main { public static String q6() { // Your code here } }