Answered step by step
Verified Expert Solution
Link Copied!

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


image

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

013547194X, 978-0135471944

More Books

Students also viewed these Programming questions

Question

LO.2 Distinguish between realized and recognized gain or loss.

Answered: 1 week ago

Question

If 2 5 9 - k 5 8 = 2 5 8 , what is the value of k?

Answered: 1 week ago

Question

How effective they are in setting objectives and achieving goals

Answered: 1 week ago

Question

Whether they possess and properly apply needed management skills

Answered: 1 week ago

Question

Summarize ten management roles

Answered: 1 week ago