school/lab-8/8.33.1-turn-exp/LabProgram.java

30 lines
887 B
Java
Raw Normal View History

2020-11-11 08:47:37 -05:00
import java.util.Scanner;
public class LabProgram {
/* Define your method here */
public static int largestNumber(int num1, int num2, int num3){
int largest = num1;
largest = (largest < num2) ? num2:largest;
largest = (largest < num3) ? num3:largest;
return largest;
}
public static int smallestNumber(int num1, int num2, int num3){
int smallest = num1;
smallest = (smallest > num2) ? num2:smallest;
smallest = (smallest > num3) ? num3:smallest;
return smallest;
}
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int num1, num2, num3;
num1 = scnr.nextInt();
num2 = scnr.nextInt();
num3 = scnr.nextInt();
System.out.println("largest: " + largestNumber(num1,num2,num3));
System.out.println("smallest: " + smallestNumber(num1,num2,num3));
}
}