1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dybincka [34]
4 years ago
6

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

Computers and Technology
1 answer:
denis-greek [22]4 years ago
6 0

Answer:

<h2>JAVA program: </h2>

import java.util.Scanner;  //Scanner class is used to get the input

public class FindSmallest // class to find the smallest of 3 integer values

{     public static void main(String[] args) //entry point of the main program

{  int number1, number2, number3;  // 3 integer type numbers are declared

       Scanner scanner = new Scanner(System.in); //

//new Scanner is an object that is pointing towards scanner to get the input

       System.out.println("Enter the first number:");

//prompts the user to enter the first integer value

       number1 = scanner.nextInt();

// nextInt() method of reads integer value entered by user

       System.out.println("Enter the second number:");

//prompts the user to enter the second integer value

       number2 = scanner.nextInt();

       System.out.println("Enter the third number:");

//prompts the user to enter the third integer value

       number3 = scanner.nextInt();

       scanner.close();         //closes scanner

   if( number1 <= number2 && number1 <= number3)

//checks the condition if number1 is less than or equal to number2 and //number3

           System.out.println(number1 + " is the smallest number");

// if condition is true then displays the messages number1 is the smallest

       else if (number2 <= number1 && number2 <=number3)

//else checks if number2 is less than or equal to number1 and number3

           System.out.println(number2 + " is the smallest number");

// if else condition is true then display that number2 is the smallest

       else

           System.out.println(number3 + " is the smallest number");    }  }

//else display number3 is the smallest.

<h2>C++ program</h2>

#include <iostream>

//includes iostream header file for input output functions

using namespace std;

//namespace is used by computer in order to detect cout endl cin. objects

int main() //start of the main program

{  int number1, number2, number3; //declares 3 integer type numbers

   cout << "Enter the first number: ";

//prompts user to enter 1st integer value

   cin >> number1;

//accepts the first input value

   cout << "Enter the second number: ";

   cin>> number2;

   cout << "Enter the third number: ";

   cin>> number3;

   if(number1 <= number2 && number1 <= number3)

/*if condition checks whether value stored in number1 is less than or equal to the values stored in number2 and number3 variables */

   { cout << number1<< " is the smallest number ";    }

//if the condition is true this means number1 is the smallest

   else if(number2 <= number1 && number2 <= number3)

/*if number1 is neither smaller than number2 nor number then program control will move to else if part which checks if number2 is less than or eqal to number1 and number3*/

   { cout << number2<< " is the smallest number ";    }

//true if else part means that number2 is the smallest

   else

    { cout << number3<< " is the smallest number ";    }}

/*in case none of the above conditions is true then else part will be exectued which means that number3 is the smallest */

<h2>Python Code</h2>

number1 = int(input("Enter the first number: "))

#prompts user to enter the first number

number2 = int(input("Enter the second number: "))

number3 = int(input("Enter the third number: "))

if (number1 <= number2) and (number1 <= number3):

#if condition checks whether value stored in number1 is less than or equal #to the values stored in number2 and number3 variables

  smallest = number1

#value of number1 will be stored in smallest if the condition evaluates to #true

elif (number2 <= number1) and (number2 <= number3):

#if number1 is neither smaller than number2 nor number then program #control will move to elif part(else if) which checks if number2 is less than #or equal to number1 and number3

  smallest = number2

#value of number2 will be stored in smallest if the elif condition evaluates #to true

else:

#in case none of the above conditions is true then else part will be #exectued which means that number3 is the smallest

  smallest = number3

#value of number3 is stored in smallest variable

print(smallest, "is the smallest number")

#smallest value stored in smallest variable is displayed as output

<h2>Explanation:</h2>

So the program is used to take three integers from the user. Next the if condition first compares number1 to number2 and number3. If number1 is less than or equals to both number2 and number3 this means that one is the smallest of the three values. If not then the else if condition will be checked. This condition checks if value in number2 variable is less than or equal to that of number1 and number3. If its true then this means that number2 is the smallest. If both if and else if conditions are false then this means that number3 is the smallest number. I have used less than or equal = to here along with the less than relative operator. The reason is that if the user enters number1 as 8 number2 as 8 and number3 as 9 then this means number1 and number2 are equal but less than number3 so the output will display 8 as the smallest number but without using = it will display 9 as the smallest number.

<h2>Output:</h2>

Enter the first number:

3

Enter the second number:

6

Enter the third number:

1

1 is the smallest number

You might be interested in
Worksheet-I • Make a list of 10 application software and 5 utility programs installed in your computer, along with their uses. U
Andru [333]

Answer:

An antivirus is a utility software that helps to keep the computer virus-free. Moreover, it notifies when any malicious file is detected and removes such files. In addition, it scans any new device attached to the computer and discards any virus if there. Moreover, it also scans the system from time to time for any threats and disposes of them. Examples of antivirus are McAfee Antivirus, Quick heal Antivirus, Windows Defender, etc.

These utility software are used to manage files of the computer system. Since files are an important part of the system as all the data is stored in the files. Therefore, this utility software help to browse, search, arrange, find information, and quickly preview the files of the system.

An important part of a computer is storage space, it is very important to maintain this storage. Therefore, we use certain utility software to compress big files and decrease their size, these are compression tools. The format of the files changes while compressing and we cannot access or edit them directly. In addition, we can easily decompress the file and get the original file back. Examples of compression tools are WinZip, WinRAR, 7-Zip, etc.

These utility software are used to manage data on disks. Moreover, they perform functions like partitioning devices, manage drives, etc. Examples of disk management tools are Mini Tool Partition Wizard, Paragon Partition Manager, etc.

This utility software helps to free up the disk space. In addition, the files which are no longer in use are removed from the disk. Examples are Cortex, C Cleaner, etc.

Explanation:

hope it helps

mark as brainiest

happy to help

ask more I'll help if I know the answer

8 0
3 years ago
The picture that graphically represents the items you use in Windows is called a/an GUI
egoroff_w [7]

That's a TLA for "<em><u>Graphical User Interface</u></em>".


8 0
4 years ago
Read 2 more answers
How to add if an statemement on a retrun in react js.
miv72 [106K]

Answer:

Of course, if we think about if statement in Javascript or Typescript logic, it’s the same as in every Javascript or Typescript place.

It’s just if/else like pure javascript, but in this case, we won’t talk about the normal if/else.

In react, we’ll need if statements for the one more thing, it’s the rendering.

It’s named “Conditional rendering”, but to make it simple, let’s stay with “if statement in react”.

There are the two most popular ways to use conditional rendering that we’ll see in the React.js code, and depends on a case, both of them are correct.

The first way that we can use is to define the conditional rendering directly in the components layout.

It’s quick and easy that we’ll use the most, and in some cases, it is the best for performance.

We’ll be using this way in the cases when we have only one condition, more just as “if”, when we would like to render some element when a specified condition is passed.

The second way is the function created to handle specified parts of the layout, and render it conditionally, to do that we can use not only if/else but the switch case as well.

This one way is right to use in cases where we have more conditions, especially the version with switch one.

But it fires the function anyway, so it is no sense to use it when we have one condition.

Let’s take a look at the code examples where I added both ways of doing that:

// The first example with the code inside functional component

function Parent(props) {

 return(

   <>

     {name === "Duomly" && (

       <DuomlyComponent/>  

     )}

   </>

 )

}

// The second example with the additional function

function renderComponent() {

 const name = 'Duomly';

 if (name === 'Duomly') {

   return 'Duomly';

 } else {

   return null;

 }

}

function Parent(props) {

 return renderComponent();

}

Explanation:

3 0
3 years ago
Knowing what you know now about frequency analysis, would you feel comfortable sending your password over the Internet using a s
Vikki [24]
According to my opinion, NO, I'd not feel comfortable.

Substitution ciphers in the world of encryption can be cracked very easily. By looking for patterns like one letter words, double letter patterns, and knowing rules such as all words must contain at least an a, e, i, o, u or y, you are probably able to decipher this with so much ease. While this information and the frequency of letters used in the encrypted message might be helpful, it might not be a perfect process.


8 0
3 years ago
Read 2 more answers
Which software is used to play, create, and modify audio and video files?
Alenkasestr [34]
Windows Movie Maker, iMovie, Final Cut Pro (x), QuickTime?
8 0
4 years ago
Read 2 more answers
Other questions:
  • A data structure used to bind an authenticated individual to a public key is the definition of ________.
    14·1 answer
  • All employees of E.C. Hoxy are required to pass through a gate and present their photo identification cards to the guard before
    10·1 answer
  • Which of the following is a disadvantage of using open source software?
    14·1 answer
  • Write methods to do the following: a. Display three full lines of asterisks on the screen. b. Accept as an argument your name, a
    5·1 answer
  • Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the arr
    6·1 answer
  • How can a System Administrator quickly determine which user profiles, page layouts, and record types include certain fields? Uni
    14·1 answer
  • What is NOT a built-in function in python?<br> sqrt()<br> string()<br> fabs()<br> O print()
    12·2 answers
  • Ten output devices you know
    10·1 answer
  • Before creating a graphic, you should _____. Select all that apply. A. export it as an SVG file B. consider whe
    12·1 answer
  • E. Write an algorithm to show 'How to prepare a cucumber sandwich?". ​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!