Given the following variable declarations and main() method skeleton driver below, code up “if” statements that correspond with each of the questions below. (A driver is a program whose purpose is to run other code, in this case, the "if" statements.) Compile and execute your code to prove it’s correct. Use a Scanner to initialize each data item.
Prompt the user with: "Enter the number". Determine if it is negative and if so, print: "The number is negative." Use a Scanner to collect the input, and report to the console if the variable called “number” is negative using System.out.println().
Prompt the user with: "Enter a second number". Determine if the number is zero and if so, print: "The number is zero." Use a Scanner to get the input, and report if the number is zero next. You can reuse the variables "number" and "keyboard" here.
Continue to use Scanner for input. Prompt the user with: "Enter a third number, a double, for the class average." Determine if the class average is a passing grade, and if so, print: "A passing grade", and print to the console otherwise if not (not passing is if the class average was below a 65).
Prompt the user with: "Is the answer the user reported true? Enter a Boolean value." Store the value in the variable called "answer". Let the user know if the value in the variable “answer” is true by printing an appropriate message to the console.
Starting with the "if" statement you built in the previous problem, add an "else" clause to it so that if the answer was false, your program will output "The value was false" instead.
Ask the user for a number and then determine if the number is even or odd. Print out “the number is even” if the “number” variable holds an even value, else { print out “the number is odd” }
Ask the user for a float value (i.e. real number, data type = float) that will represent a grade and determine if the grade is in the “A” range. Print to the console “The grade is above an X” (where X is the minimum value for an "A" grade) if the grade is an “A”. (See the grading tables linked in the Syllabus for the value.)
Add to the previous "if" statement so that it becomes an "if/else" structure that will now also test to see if the grade is a “B”? Output to the console if the grade is in that range. (Note the use of “&&” for logical "and" in Java.)
Ask the user for a temperature, stored in a double. Is the temperature higher than 78 degrees or less than (or equal to) 78 degrees? Describe the current temperature as “higher than 78 degrees” or “less than or equal to 78 degrees”.
For the temperature, write an "if/else" statement that asks if the temperature is (positive AND odd) OR (zero AND even)? (Notice the use of parenthesis here to define operator precedence. Look up order of operations (PEMDAS) and “logical AND” if this is unfamiliar in your text). If it is, output “yes; positive and odd, or zero and even.” and if it’s not, say “no; not positive and odd” on the console.