PART B. Write a program Smallest that reads three integers from the user and determines the smallest valueFor example:Enter three integers, I'11 find the smallest: 4 9 2The smallest is: 2Note: In PART B and PART C, your program must handle cases where the numbers entered are repeated. Inother words, the three numbers may not necessarily be unique. For example, 7 3 7 in sorted order is 3 7 7 andthe smallest number is 3

Question
89 views

////////////

////////////

////////////

check_circle

Step 1

Program Instructions:

• Use scanner class object to read the three integers.
• Create a method names Smallest and pass the three integers to it.
• In method Smallest(), compare the numbers to find the smallest of them.
Step 2

Program:

import java.util.Scanner;

class Main{

public static void main (String args[]){

//create a scanner object for input

Scanner scan=new Scanner(System.in);

// take input from user

System.out.print("Enter three integers, I'll find the smallest: ");

int num1=scan.nextInt();

int num2=scan.nextInt();

int num3=scan.nextInt();

scan.close();

//calling the method

Smallest(num1,num2,num3);

}

static void Smallest(int num1,int num2, int num3){

// check the smallest

if(num1<=num2 && num1<=num3){

System.out.println("The smallest is: "+num1);

...

Want to see the full answer?

See Solution

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in