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
How should you dress for a phone interview
artcher [175]
If you're doing an interview via phone I wouldn't suppose you would need to get dressed into anything specific. If it's going to be a video call, then you should at least wear something presentable  that the camera will see (that means you don't have to wear pants). 
Sorry, if you're looking for some specific answer then I can't help you. This question just kinda throws common sense out there and it's just your job to use it. 
5 0
4 years ago
Read 2 more answers
Hey! I was recommended a site “9anime” the other day. All’s been going well but I accidentally taped on a new dub settingZ somet
Studentka2010 [4]

Answer:

yep defiantly virus

Explanation:

8 0
2 years ago
Read 2 more answers
The computer that can be used for performing the daily life tasks that might include emailing, browsing, media sharing, entertai
ad-work [718]

Answer:

Yes, this statement is completely true

Explanation:

Yes, this statement is completely true. A personal computer is a multimedia machine and can be used to complete an incredibly large number of tasks with ease. Such tasks include all of the ones listed in the question. Aside from that other tasks depend more on the skill level and understanding of the user. For example, an individual who has a vast understanding of technology and programming can create software to perform absolutely any task they may want or need to do.

5 0
3 years ago
Pick a web browser (a leading one or perhaps a lesser-known one that you use) and examine the Privacy and Security features and
Veseljchak [2.6K]

Solution :

<u>Chrome web browser</u>

The Chrome web browser uses a range of privacy and security settings for its customers. They include several security indicators as well as malware protection. Chrome uses the sandboxing technology, which prevents the harmful viruses and Trojans from reaching the computers.

Chrome provides a safe browsing by giving us an alert whenever we try to browse some harmful web sites.  It also warns you if we use a username and password combination which has been compromised in any data leak.

Chrome also serves to protect the individuals :

It provides a features of Ad blocking.

When we want to browse safely without being recognized or without storing any credentials, Chrome provides an Incognito mode.

Many businesses can be done on the internet using Chrome platform that is safe and authenticate to gather and collect data and information.

3 0
3 years ago
____ is designed for short-distance connections and has only a few lambdas, with a greater space between lambdas. Group of answe
givi [52]

Answer:

The answer is Coarse wavelength division multiplexing (CWDM)

Explanation:

CWDM is the wavelength designed for short- distance connections  and has only a few lambdas. It is mostly used nowadays as a type of wavelength technologies deployed in cities and inner access ways. It is inexpensive and thus a cost effective wavelength  division multiplexing. Cost effective lasers can be used in CWDM due to the spacing of about 20nm between its wavelengths.

4 0
3 years ago
Read 2 more answers
Other questions:
  • "Once a business operations analysis is completed and change needs to
    7·2 answers
  • Why is compression a "hard problem" for computers? Draw on your own experience compressing text with the text compression widget
    12·1 answer
  • A) Write 600 as the product of prime factors.<br> Give your answer in index form.
    7·2 answers
  • 1. In your own words, describe the purpose of a for a loop.
    11·1 answer
  • A. Calculate the diffusion coefficient for magnesium in aluminum at 450°C.
    14·1 answer
  • Match each proofreading mark to the expected result.
    10·1 answer
  • Implement a program called genes.py that does the following: a. Reads a DNA sequence t as command-line argument b. Reads strings
    9·1 answer
  • ____ is a technique for confirming that q received packet or frame is likely to match what was sent
    15·1 answer
  • Create a public class Dog that stores a single double age set by the constructor. (Reject negative ages using assert.) Dog shoul
    13·1 answer
  • Risk taker positive or negative​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!