Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// DebugFive4.java // Outputs highest of four numbers import java.util.*; public

ID: 3747375 • Letter: #

Question

// DebugFive4.java
// Outputs highest of four numbers
import java.util.*;
public class DebugFive4
{
public static void main (String args[])
{
Scanner input = new Scanner(System.in);
int one, two, three, four;
String str, output;
System.out.println("Enter an integer");
str = input.next();
> System.out.println("Enter an integer");
str = input.next();
two = Integer.parseInt(str);
System.out.println("Enter an integer");
str = input.next();
three = Integer.parseInt(str);
System.out.println("Enter an integer");
str = input.next();
four = Integer.parseInt(str);
if(one > two > one > three > one > four)
output = "Highest is " + four;
else
if(two > one && two > three !! two > four)
output = "Highest is " + three;
else
if(three > one && three > two && three > four)
output = "Highest is " + three;
else
output = "Highest is " + four;
System.out.println(output);
}
}

MINDTAP From Cengage Debugging Exercise 5-4 Instructions DebugFive4.java+ 1// DebugFive4.java 2 // Outputs highest of four number 3 import java.util.*; 4public class DebugFive4 The files provided in the code editor to the l right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly 6 public static void main (String args[]) Scanner input -new Scanner (System.in); int one, two, three, four String str, output; System.out.println( "Enter an integer") str-input.next); oneInteger.parseInt(str); System.out.println("Enter an integer"); str input.next); two Integer.parseInt(str); System.out.println("Enter an integer; str input.next) three Integer.parseInt (str); System.out.println("Enter an integer" str-input.nextO; fourInteger.parseInt(str); if (onetwoone threeonefour Grading 9 10 Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade 12 13 14 15 16 17 18 19 20 21 Once you are happy with your results, click the Submit button to record your score 23 24 25 26 27 28 29 30 utput "Highest is"four else if(two > one && two > three two four) output"Highest is "three; else if(three>one &&three two && three four) output "Highest is " three;

Explanation / Answer

import java.util.*;

public class DebugFive4{

public static void main(String []args){
  
Scanner input = new Scanner(System.in);
int one, two, three, four;
String str, output;
System.out.println("Enter an integer");
str = input.next();
> System.out.println("Enter an integer");
str = input.next();
two = Integer.parseInt(str);
System.out.println("Enter an integer");
str = input.next();
three = Integer.parseInt(str);
System.out.println("Enter an integer");
str = input.next();
four = Integer.parseInt(str);
  
if(one >= two && one >= three && one >= four ) /* conditions for first number is Highest */
output = "Highest is " + one;
else
if(two >= one && two >= three && two >= four) /* conditions for second number is Highest */
output = "Highest is " + two;
else
if(three >= one && three >= two && three >= four) /* conditions for third number is Highest */
output = "Highest is " + three;
else
output = "Highest is " + four; /* If all are less then last number is Highest */
System.out.println(output);

}
}