It displays the max number, but in the conditions everything is checked off except that "the program should display the max number". It displays the max number in the output.
I noticed I have this problem with if/if-else statements. If anyone can explain or maybe link to another source that explains the logic of it more that would be nice. It's fairly simple to understand but I always wonder why I have issues with these sometimes.
package com.codegym.task.task04.task0419;
/*
Maximum of four numbers
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String num1 = reader.readLine();
String num2 = reader.readLine();
String num3 = reader.readLine();
String num4 = reader.readLine();
int a = Integer.parseInt(num1);
int b = Integer.parseInt(num2);
int c = Integer.parseInt(num3);
int d = Integer.parseInt(num4);
if (a >= b && a >= c && a >= d){
System.out.println(a);
}
else if (b >= a && b >= c && b >= d){
System.out.println(b);
}
else if (c >= a && c >= b && c >= d){
System.out.println(c);
}
else if (d >= a && d >= b && a >= c){
System.out.println(d);
}
else
System.out.println(a);
}
}