Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

University of Washington Main Method Skeleton Drive Project

University of Washington Main Method Skeleton Drive Project

University of Washington Main Method Skeleton Drive Project

I need an explanation for this Java question to help me study.

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.

  1. 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().
  2. 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.
  3. 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).
  4. 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.
  5. 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.
  6. 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” }
  7. 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.)
  8. 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.)
  9. 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”.
  10. 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.
  11. Prompt the user for a letter grade and store this in a char.  Then, write a multi-way “if” statement that ends in a catch-all if a non-existent letter grade (i.e., not A, B, C, D, F) is entered.  The multi-way “if” asks:  Is the grade an “A”? Else is the grade a “B”? Else is the grade a “C”? Else is the grade a “D”? Else is the grade an “F”?  For each case, print an appropriate message to screen as to what letter grade was entered (or if a non-existent grade was entered). Notice the use of the word else in the sentence above, which provides for a more precise meaning.  In spoken English we might use the word “or” instead, but of course, English is terribly ambiguous and Java needs to be discrete, deterministic, and precise.
  12. Write a method called “max” that takes two integers as input and returns the larger of the two.  That is, complete the function “public static int max(int a, int b) {“ so that it returns the larger of a or b using an “if” statement (hint: lab #2 has a similar question, using Math methods. Your job is to build a method that will perform the same functionality as Math.max)
  13. Ask the user for two integers using a Scanner and report the largest and smallest values using the max method you just built.  Consider the following output:

//sample output for problem 13
Enter two integers: 2 14       
Largest is 14
Smallest is 2

Main Method Skeleton Driver

    //Driver for if statement warm-up

public static void main(String[] args) {

         Scanner keyboard = new Scanner(System.in);  

         //TODO 1

         System.out.println(“Enter the number for TODO 1”);
         int number = keyboard.nextInt();
         if( the number is negative ) {  //you must fix this pseudocode before you can compile it
             System.out.println(“The number is negative”);

         //TODO

         number = ?;

         //TODO 3

double average = ?;

         //TODO 4 & TODO 5

boolean answer = ?;

         //TODO 6

         number = ?;

         //TODO 7

         float grade = ?; 

         //TODO 8

         grade = ?;

         //TODO

double temperature = ?;

         //TODO 10        

         number = ?;

         //TODO 11

char letterGrade = ?; 

         //TODO 12:  See below for the max function/method

         //TODO 13

    }   

public static int max(int a, int b) {

         //TODO 12

    }

Notes and Hints

  • Always compile and run/test your code after each incremental change.
  • Never write a whole program first and then compile and test later.

Grading

Each item is worth 2 points.  For this assignment, points are awarded strictly based on whether your program is correctly written to produce the correct results.  You will not be graded on style, though you should always practice good programming style.

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20