I need to write the program that outputs the median of 3 numbers using a,b,c unfortunately i have an error there that says:"java:21: error: 'else' without 'if'
else
^
1 error"
My code:
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b, c;
System.out.print("a=");
a = sc.nextInt();
System.out.print("b=");
b = sc.nextInt();
System.out.print("c=");
c = sc.nextInt();
if (c<a && a<b || b<a && a<c);
{
System.out.println(a);
}
if (c<b && a>b|| a<b && c>b);
{
System.out.print(b);
}
else
{
System.out.print(c);
}
sc.close();
}
}
The error is in the 21st line I tried to replace else with if It didnt work.