Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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[] 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
Step: 1
The code has several syntax errors and issues that need to be addressed Here is the corrected versio...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started