Question: Q2.1 Find the bug 8 Points The following code is intended to continuously get user integer input and print a message based on the values



Q2.1 Find the bug 8 Points The following code is intended to continuously get user integer input and print a message based on the values input. Specifically, if the integer is: . . 1: print "create a file." 2: print "open a file." 3: print "close a file." 4: print "delete a file." The program will end if the user inputs any other integer values. -PP000 UTAWNA 1 public class Loop1 2 { 3 public static main (String[] args) 4 { 5 while (true) 6 { 7 int op = stdin.readInt(); 8 if (op == 1) 9 Stdout.println("create a file."); 10 else if (op == 2) 11 Stdout.println("open a file."); 12 else if (op 3) 13 Stdout.println("close a file."); 14 else if (op == 4) 15 Stdout.println("delete a file."); 16 } } 18 } == 17 The program does not work as intended. Answer the following questions: (1) What code do you need to add? and (2) Where do you need to add this code to fix the program? Q2.2 Write some code 12 Points Write a snippet of code that among the integers from 1 to 99 prints all integers that are divisible by three. The printed integers should be separated in different lines and each line except the last one has 5 integers. Use a for loop for this question. Enter your answer here Q2.3 Find the bug 10 Points There is a bug in the following code. 1 public class Loop2 2 { 3 public static main (String[] args) 4 { 5 int n = Integer.parseInt(args[0]); 6 int i = 1; 7 while ( i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
