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
olga55 [171]
3 years ago
6

java Two smallest numbers Write a program that reads a list of integers, and outputs the two smallest integers in the list, in a

scending order. The input begins with an integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and fewer than 20 integers. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 and 3 To achieve the above, first read the integers into an array. Hint: Make sure to initialize the second smallest and smallest integers properly.
Computers and Technology
1 answer:
SashulF [63]3 years ago
7 0

Answer:

The code to this question can be defined as follows:

import java.util.*;//import package for user input

public class Main //defining a class

{

public static void main(String[] args)//defining main method  

{

   int m1,m2,num,t,i;//defining integer variable

   Scanner incx = new Scanner(System.in);//creating Scanner class object

   m1 = incx.nextInt();//input value

   m2 = incx.nextInt();//input value  

   if (m1 > m2)//use if block to check m1 greater than m2  

   {//swapping value

       t = m1;//holding m1 value in t

       m1 = m2;//defining m1 that take m2

       m2 = t;//holding m2 value  

   }

   for (i = 2; i < 6; i++)//defining for loop  

   {

       num = incx.nextInt();//input value  

       if (num < m1) //defining if block to smallest value

       {

           m2 = m1;//holding m2 value in m1

           m1 = num;//holding num value in m1

       }  

       else if (num < m2)//defining if block to smallest value  

       {

           m2 = num;//holding num value in m2

       }

   }

       System.out.println(m1 + " " + m2);//print two smallest values

   }

}

Output:

5

10

5

3

21

2

2 3

Explanation:

In the above code, five integer variable "m1, m2, num, t, and i" is declared, in which it creates the scanner class object for inputs the value and use m1 and m2 use to the input value.

In the next step, if a block is used to swap the value and pass into the for loop that use if block to find the two smallest values and hold its value into the m1 and m2 and print its value.

You might be interested in
Give two examples of situations or applications where electrical circuits are used.
Pavlova-9 [17]

Answer:

lamps, electric motors

Explanation:

5 0
3 years ago
If you’re storing some personal information like Debit/Credit card numbers or Passwords etc, on different sites for running you’
nata0808 [166]

Answer:

cookies are stored on client side.

A hacker would need access to your computer, either by physically reading the cookie data or by means of cross-site scripting.

Other than that, cookies should not contain passwords or credit card numbers, just things like preferences or session identifiers.

3 0
3 years ago
Signed ints versus unsigned ints:
julia-pushkina [17]
The answer is c !!!!!!!!!
7 0
4 years ago
Write a program that passes an unspecified number of integers from command line and displays their total.
Svetradugi [14.3K]

Answer:

Explanation:

I will go straight to the code, and hope it didn't confuse you.

Here is it

public static void main(String[] args)

int [] x = new int [args.length]

for (int y = 0; y< args.length;yi++)

int[y] = (int) args [y]

5 0
3 years ago
You are asked to assume the role of an employee of the DigiFirm Investigation Company. As part of its community outreach effort,
kirill [66]

Answer:

1.  To trace an email we need to examine the header part of the email. By examine the header of an email we could extract the sender, subject and other important credentials related to that email.  

2. The command to trace the email id is “whois” command.

 First open the email client and find the IP address of the received email that need to be traced.  The command “whois” IP address gives the registration information of that IP address.

 3.  Reverse address/email search is the procedure used by the experts to find the origin or the ownership of the email.  Rather than tools websites are more use full in the reverse address search.

http://reverse.addresssearch.com, www.iplocation.net, etc. are good to find the ownership of an email.

4. We need to set up mail server to send, receive and to explore various activities associated with an email.  The other related purpose servers like SMTP server, HTTP server , etc are also required to assist large organizations.  The mail server can be a stand-alone computer or a collection of computer and servers.

 5.  The executable files should be examined thoroughly in the server, it can be dangerous malwares.  The examination is mainly done by scanning for malicious words and sender address.  Since many mail providers does not allow executable files to send, so the attackers are using other files also as a carrier of the malwares, so now every emails should be subject to deep examination using some malware scanner.  

6.   By the time of examination the some of the legitimate mails may also come under the suspect list so further check is needed there.  At the same time the attacks can be from legitimate sources also this could be go un-noticed; this should be also a challenge to face in the stage of e-mail examination.

8 0
3 years ago
Other questions:
  • Which is the main function of the arithmetic and logic unit (ALU)?
    5·2 answers
  • A neologism is defined as:
    5·1 answer
  • Who is the inventor of cpu?
    5·1 answer
  • The keyboard preferences pane includes a list of keyboard shortcuts.
    8·1 answer
  • If the user loads this graphic in a text only browser how will the browser describe it?
    11·2 answers
  • What will happen if you reverse the connection of IDE?<br>​
    9·1 answer
  • Treat others the way
    5·2 answers
  • Hey does anyone know any sites like you tube i can watch on my school chrome book or tell me how to unblock sites cause everythi
    8·1 answer
  • Heeeeeeeelp :)<br> thx<br> jfdyiusjmkdsuiho;dmcvrvho;j
    5·2 answers
  • Which of the following factors is most likely to result in low shipping and handling costs? A higher than average hourly pay rat
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!