Question: analyze the code and fix the error Main.java 2 public class Main 3- { 4 public static void main(String[] args) { 5 6 Scanner myObj-new

analyze the code and fix the error


Main.java 2 public class Main 3- { 4 public static void main(String[]

Main.java 2 public class Main 3- { 4 public static void main(String[] args) { 5 6 Scanner myObj-new Scanner(System.in); 7 int count = 0; // sets count to zero CO G Run 8 double tot = 0, num = 0, min = 0, max = 0, average; 9 10 System.out.println("Enter Five Values"); 11 do { 12 try { 13 System.out.print("Enter Value (count 14 num = myObj.nextDouble(); 15 16 if (min == 0) min = num; 17 if (num min) min = num; 18 if (num > max) max = num; 19 tot += num; 20 count++; 21} 22 catch (Exception e) { 23 24 + 1) + " "); System.out.println("Invalid value entered. Try again."); myObj.nextLine(); 25 } 26 } 27 while (count < 5); 28 System.out.println("The Total is: + tot); * tot .20); 29 System.out.println("Your average is " + average); 30 System.out.println("Your minimum number is " + min); System.out.println("Your maximum number is " + max); System.out.println("Interest on total at 20% = 31 32 33 } 34 } + 35 Output javac /tmp/InmgHx0CzW/Main.java Clea /tmp/InmgHx0CZW/Main.java:29: error: variable average might not have been initialized System.out.println("Your average is " + average); 1 error

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code has several syntax errors and issues that need to be addressed Here is the corrected versio... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!