Engineering

Computer ScienceQ&A LibraryPART 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 3Question

Asked Sep 18, 2019

89 views

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

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

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

please help me solve this problem in java

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);

...

Tagged in

Find answers to questions asked by student like you

Show more Q&A

Q: In PL/SQL, Create a recursive store function called add_numbers to calculate the total of all consec...

A: Program plan:Declare the required variables.The “add_numbers” function returns the value. Otherwise,...

Q: need help with understanding how to do the SQL code for the following question: These are the heade...

A: As the table name is not shown in the picture, we are assuming the table name as Product. There are ...

Q: Construct an unambiguous grammar equivalent to the grammar in S→AB|aaaB, A→a|Aa, B→b.

A: Solution: Construct an unambiguous grammar to grammar.Given that,S -> AB|aaaBA -> a|AaB -> ...

Q: Decrypt the following shift cipher. (Show work) NFRNSIZVZJXSJZSNAJWXNYD'XKNXMJWMFQQ What is the pl...

A: Ceasar cipher:The Ceasar cipher is one of the simplest and oldest known ciphers.In this cipher, each...

Q: Hi, Please,I have a question with Python,I have to create a Loop and terminate BMI calculation flow...

A: The loop of flow chart for BMI is given as:

Q: what is the best test strategy for any ERP system?

A: ERP stands for Enterprise resource planning is a software used for business process management. It a...

Q: Make truth tables, then use them to create equations in SOP and POS format. Explain your steps.1) xy...

A: Truth table for the expression: F = xyz+ x~(yz) + ~(xyz)

Q: (Method Overloading) Given the following methods, write down the printed output of themethod calls: ...

A: Answer with Explanation:“doSomething(5)” contains an argument integer “5” and it is called to the “d...

Q: Question: Write a function to display a pattern as follows: 1 2 1 ... ... n n-1 ...

A: Solution:The python program has the following algorithm:In the displayPattern() function,Declare and...