Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

3.

20 LAB: Smallest number


Write a program whose inputs are three integers, and whose output is the smallest
of the three values.

Ex: If the input is: 7 15 3


the output is: 3

CODE (JAVA):

import java.util.Scanner;

public class LabProgram {


public static void main(String[] args) {
int num1;
int num2;
int num3;

Scanner scnr = new Scanner(System.in);


num1 = scnr.nextInt();
num2 = scnr.nextInt();
num3 = scnr.nextInt();

int smallest = Math.min(num1, Math.min(num2, num3));

System.out.println(smallest);
}
}

You might also like