import java.util.Scanner;
class CurrencyExchange_1 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("Input any 3 numbers");
int firstnumber = sc.nextInt();
int secondnumber = sc.nextInt();
int thirdnumber = sc.nextInt();
//Finding the bigger number
if (firstnumber > secondnumber);
if (firstnumber > thirdnumber ) {
System.out.println("Biggest number is " +firstnumber);
} else if (secondnumber > firstnumber);
if (secondnumber > thirdnumber); {
System.out.println("Biggest number is " +secondnumber);
} **else if** (thirdnumber > firstnumber);
if (thirdnumber > secondnumber); {
System.out.println("Biggest number is " +thirdnumber);
}
}
}
For the bolded part, I originally wrote < else > only without the conditions but it was an error. Even with the code as written above, an error prompts for <'else' without 'if'>. I am not too sure where went wrong as when I completely delete the last < "else" > part, the code works perfectly. I was reading answers for other questions that <else {...}> can work perfectly when not all conditions are met but it seems to be incorrect for me. Please pardon my complicated code because I am currently learning the basics and I am required to solve it using what I know currently which is just the comparing part of programming.
Also, is it me or there is a lot of auto-correct going on? Some words keep changing back when I have clearly edited them!
Thank you all for your kindness! I finally understand my errors! Would like to thank each of y'all personally but to prevent clutter, i'm going to write it here!