Problem 2
State whether each of the following is true or false. If \(f\) a cain why. a) Comments cause the computer to print the text after the // on the screen when the program executes. b) All variables must be given a type when they are declared. c) Java considers the variables number and NuMbEr to be identical. d) The remainder operator ( \(\%\) ) can be used only with integer operands. c) The arithmetic operators \(", /, \$,+\) and \(-\) all have the same level of precedence.
Problem 3
Write statements to accomplish each of the following tasks: a) Declare variables \(c,\) this IsAVariable, \(q 76354\) and number to be of type int. b) Prompt the user to enter an integer. c) Input an integer and assign the result to int variable value. Assume Scanner variable input can be used to read a value from the keyboard. d) If the variable number is not equal to \(7,\) display "The variable number is not equal to \(7 "\) e) Print "This is a Java program" on one line in the command window. f) Print "This is a Java program" on two lines in the command window. The first line should end with Java. Use method System.out.print1n. g) Print "This is a Java program" on two lines in the command window. The first line should end with Java. Use method System. out.printf and two \(\%\) s format specifiers.
Problem 5
Write declarations, statements or comments that accomplish each of the following tasks: a) State that a program will calculate the product of three integers. b) Create a Scanner that reads values from the standard input. c) Declare the variables \(x, y, z\) and result to be of type int. d) Prompt the user to enter the first integer. e) Read the first integer from the user and store it in the variable \(x\). f) Prompt the user to enter the second integer. g) Read the second integer from the user and store it in the variable \(y\). h) Prompt the user to enter the third integer. i) Read the third integer from the user and store it in the variable \(z\). jompute the product of the three integers contained in variables \(x, y\) and \(z,\) and assign the result to the variable result. k) Display the message "Product is" followed by the value of the variable result.
Problem 8
Write Java statements that accomplish each of the following tasks: a) Display the message "Enter an integer: ", leaving the cursor on the same line. b) Assign the product of variables b and c to variable a. c) State that a program performs a sample payroll calculation (i.e., use text that helps to document a program).
Problem 9
State whether each of the following is true or false. If false, explain why. a) Java operators are evaluated from left to right. b) The following are all valid variable names: _under_bar_s \(m 928134,\) t5, j7, her_saless, his_saccount_total, a, bs, c, zand z2. c) A valid Java arithmetic expression with no parentheses is cvaluated from left to right. d) The following are all invalid variable names: \(3 g, 87,67 h 2,\) h22 and \(2 \mathrm{h}\).
Problem 11
Which of the following Java statements contain variables whose values are modified? a) \(p=i+j+k+7\) b) System.out.printlnC "variables whose values are destroyed" ) : c) System.out.println( \(\left.^{\prime} a=5^{\prime \prime}\right)\) d) value \(=\) input.nextint ();