Write 2-3 lines of code to:  Declare a String variable and…

Write 2-3 lines of code to:  Declare a String variable and save your favorite animal in it. Print the value of the variable to the console with a newline character after it.  Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.

Complete the following code. Make sure to complete the code…

Complete the following code. Make sure to complete the code in such a way that doesn’t invalidate the comments and that no implicit conversions are taking place on assignments of primitive data types. [import]public class Test {    public static void main(String[] args) {       int width;       double area;                // create a keyboard Scanner        Scanner scanner = [init]        // get a double value from the user       area = [double]        // get an integer value from the user       width = [int]       // compute the height       double height = area / width;       // print height to 1 decimal place   [print]    }} 

Convert the following switch statement to an if-else block s…

Convert the following switch statement to an if-else block so the output is the same for all cases. Assume the switch variable is already declared and initialized. Note that some lines may need to be blank, if that is the case and there are multiple lines in the block, the blank line MUST BE THE LAST LINE in the block.  For example (follow this format):   if (a == 10) { sum += 10; //LEAVE BLANK }   Instead of (do NOT do this):   if (a == 10) { //LEAVE BLANK sum += 10; }  Some lines may be used once, never, or multiple times.  switch (doggo) { case ‘r’: System.out.println(“rocko”); case ‘c’: System.out.println(“chispa”); break; default: System.out.println(“nope”); case ‘m’: System.out.println(“moccita”); }     if (1._______________) {  2._______________________ 3._______________________ } else if (4._______________) { System.out.println(“chispa”); } else if (5.________________) {  System.out.println(“moccita”); } else { 6._______________________ 7._______________________     } 

Complete the following code. Make sure to complete the code…

Complete the following code. Make sure to complete the code in such a way that doesn’t invalidate the comments and that no implicit conversions are taking place on assignments of primitive data types.  [import] public class Test {     public static void main(String[] args) {         int items;         double totalCost;         // create a keyboard Scanner         Scanner scanner = [init]         // get an integer value from the user         items = [int]          // get a double value from the user         totalCost = [double]          // compute avg         double avg = totalCost / items;         // print avg to 3 decimal places     [print]    } } 

Write 2-3 lines of code to:  Declare a String variable and…

Write 2-3 lines of code to:  Declare a String variable and save your major in it. Print the value of the variable to the console with a newline character after it.  Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.

Convert the following switch statement to an if-else block s…

Convert the following switch statement to an if-else block so the output is the same for all cases. Assume the switch variable is already declared and initialized. Note that some lines may need to be blank, if that is the case and there are multiple lines in the block, the blank line MUST BE THE LAST LINE in the block.  For example (follow this format):   if (a == 10) { sum += 10; //LEAVE BLANK }   Instead of (do NOT do this):   if (a == 10) { //LEAVE BLANK sum += 10; }  Some lines may be used once, never, or multiple times.  switch (theOffice) { case 1: System.out.println(“Jim: tuna”); case 2: System.out.println(“Michael: world’s greatest boss”); break; default: System.out.println(“nae”); case 3: System.out.println(“Dwight: assistant regional manager”); }     if (1._______________) {  2._______________________  3._______________________ } else if (4._______________) {  System.out.println(“Michael: world’s greatest boss”); } else if (5.________________) {  System.out.println(“Dwight: assistant regional manager”); } else {  6._______________________  7._______________________     }