Write a Java program which accepts three integer values and prints the maximum and minimum.
2. Write a Java program which accepts three integer values and prints the maximum and minimum.
import java.util. *;
class labbook{
public static void main(String args[]){
Scanner sc = new Scanner(System.in );
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a > b & a > c){
System.out.println("larger value is:"+a);
}
else if (b > a & c < b){
System.out.println("larger value is:"+b);
} else {
System.out.println("larger value is:"+c);
}
}
}
10 30 21 larger value is:30
Post a Comment