Question
Asked Sep 18, 2019
89 views

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

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

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

please help me solve this problem in java 

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

Image Transcriptionclose

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

fullscreen
check_circle

Expert Answer

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

Check out a sample Q&A here.

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

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

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,...

question_answer

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 ...

question_answer

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 -&gt; AB|aaaBA -&gt; a|AaB -&gt; ...

question_answer

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...

question_answer

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:

question_answer

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...

question_answer

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)

question_answer

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...

question_answer

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...