I need help with the part 3 of debugging and correction of program part so it can run properly. My debugger is not giving me the exact result as asked in the manual, so please help with that and correct the program so it run and display result as below. (Following algoritham 1 in manual) Program I wrote following the manual and ran debugger on:- package homework; import java.util.Scanner; public class Lab4 { public static void main(String[] args) { Scanner input = new Scanner(System.in); //Display result to input integer System.out.print("Enter value for a: "); int a = input.nextInt(); System.out.print("Enter value for b: "); int b = input.nextInt(); System.out.print("Enter value for c: "); int c = input.nextInt(); System.out.print("Enter value for d: "); int d = input.nextInt(); //Display result of answers System.out.println(“The larger of a and b is ” + larger); int larger = max(a,b); System.out.println(“The largest of a, b, and c is ” + largestOfThree); int largestOfThree = max(a,b,c); System.out.println(“The largest of a, b, c, and d is ” + largestOfFour); int largestOfFour = max(a,b,c,d); } } } Display Result :- Enter value for a: 4 Enter value for b: -9 Enter value for c: 7 Enter value for d: 10 The larger of a and b is 4 The largest of a, b, and c is 7 The largest of a, b, c, and d is 10
I need help with the part 3 of debugging and correction of program part so it can run properly. My debugger is not giving me the exact result as asked in the manual, so please help with that and correct the program so it run and display result as below. (Following algoritham 1 in manual)
Program I wrote following the manual and ran debugger on:-
package homework;
import java.util.Scanner;
public class Lab4 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//Display result to input integer
System.out.print("Enter value for a: ");
int a = input.nextInt();
System.out.print("Enter value for b: ");
int b = input.nextInt();
System.out.print("Enter value for c: ");
int c = input.nextInt();
System.out.print("Enter value for d: ");
int d = input.nextInt();
//Display result of answers
System.out.println(“The larger of a and b is ” + larger);
int larger = max(a,b);
System.out.println(“The largest of a, b, and c is ” + largestOfThree);
int largestOfThree = max(a,b,c);
System.out.println(“The largest of a, b, c, and d is ” + largestOfFour);
int largestOfFour = max(a,b,c,d);
}
}
}
Display Result :-
Enter value for a: 4
Enter value for b: -9
Enter value for c: 7
Enter value for d: 10
The larger of a and b is 4
The largest of a, b, and c is 7
The largest of a, b, c, and d is 10
Step by step
Solved in 3 steps with 2 images