Question: 26) (12 marks) Consider the following partial program. There are six (6) syntax and/or logic errors in the code below. Circle each error and state
26) (12 marks) Consider the following partial program. There are six (6) syntax and/or logic errors in the code below. Circle each error and state whether it is a logic error or a syntax error. Also, show how the error could be corrected. You don't need to rewrite everything, just make a note of the correction. Note: I've hard-coded some values to simplify the program. DON'T SPEND all of your time on this question Come back to it if you are stuck.*** public class SimpleMath public static void main (String[ args) string calculate "yes" //if the user wants to proceed calculate some things if (calculate "yes") int num1-100: int num2 = 200; int sum = num1 + num2; int difference Math.abs (num1 num2) int average (numl +num2) /2 int max0 int avg = 0; if (numl > num2) ( max-numl; min = num2 ; ace sing Cutly be isSi else max = num2; min numl; //print the results System.out.printin ("Sum: "+sum) ; System.out.printin ("Max: "max) : System.out.println ("Min: "+ min) ; System.out.println ("Avg:" + avg) i Thee else Iu w a System.exit (o) hure
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
