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
Julli [10]
4 years ago
14

two Smallest (10 points). Write a program TwoSmallest.java that takes a set of double command-line arguments and prints the smal

lest and second-smallest number, in that order. It is possible for the smallest and second-smallest numbers to be the same (if the sequence contains duplicate numbers). Note: display one number per line. Hint: Double.MAX_VALUE is the largest real number that can be stored in a double variable.
Computers and Technology
1 answer:
Umnica [9.8K]4 years ago
4 0

Answer:

Below is the program TwoSmallest.java with each step explanation in form of comments.

public class TwoSmallest {                     // class definition

//main class having string args as a parameter

   public static void main(String[] args)

{ if (args.length < 2)

{         //string length must not be less than 2 for proceeding

           System.out.println("Please provide double values as command line arguments");

  }

else {  

// first two entries of string are checked for min1 and min2 and stored in variables with data type double

           double min1 = Double.parseDouble(args[0]), min2 = Double.parseDouble(args[1]), num;

//when min1 will be greater than min2 it will be stored temporary in variable temp having data type double

           if (min1 > min2) {

               double temp = min1;

               min1 = min2;

               min2 = temp;  //value of temp will be stored in min2

           }

//loop will check for each entry remaining until the last character of string

           for (int i = 2; i < args.length; i++) {

               num = Double.parseDouble(args[i]);

               if (num < min1) {

                   min2 = min1;

                   min1 = num;

               } else if (num < min2) {

                   min2 = num;

               }

           }

//min1 will give the 1st minimum number and min2 will give 2nd minimum.

           System.out.println(min1);

           System.out.println(min2);  

//both characters will be printed in sequence

       }

   }

}

You might be interested in
Which would you trade on a stock exchange? A: Shares B: Bonds C: Annuities
Ivan
Most likely you would trade shares
7 0
3 years ago
Read 2 more answers
Match the components of a blog to their descriptions.
motikmotik

Answer:

Explanation:

1. entry title - name of the posting

2. permalink - place where a blog posting is located

3. entry date - when the posting became available

4. comment - allows users to add to the conversation

3 0
3 years ago
__________ refers to the coupling of data stored in files and the specific programs required to update and maintain those files
atroni [7]
I think it is good for the environment
7 0
4 years ago
How do Humza's videos counter hate speech and xenophobia
o-na [289]

Humza's videos counter hate speech and xenophobia as he doesn't let the negativity get to him, he tries and succeeds to make positive changes for unity.

<h3>What is xenophobia?</h3>

The fear or hate of everything that is viewed as being alien or weird is known as xenophobia. It is a manifestation of perceived conflict between an ingroup and an outgroup and may take the form of mistrust of one another's actions, a wish to have them removed, or concern over losing one's ethnic, racial, or national identity.

Simply described, xenophobia is the fear or dislike of strangers or foreigners; it manifests itself in prejudiced attitudes and behaviors and frequently ends in violence, abuse of any kind, and displays of hatred. In this case, it should be noted that he preached love and the importance of being united.

Therefore, Humza's videos counter hate speech and xenophobia as he doesn't let the negativity get to him, he tries and succeeds to make positive changes for unity.

Learn more about xenophobia on:

brainly.com/question/24366668

#SPJ1

8 0
2 years ago
Please convert this for loop into while loop
spayn [35]

Answer:

The code segment was written in Python Programming Language;

The while loop equivalent is as follows:

i = 1

j = 1

while i < 6:

     while j < i + 1:

           print('*',end='')

           j = j + 1

     i = i + 1

     print()

Explanation:

(See attachment for proper format of the program)

In the given lines of code to while loop, the iterating variables i and j were initialised to i;

So, the equivalent program segment (in while loop) must also start by initialising both variables to 1;

i = 1

j = 1

The range of the outer iteration is, i = 1 to 6

The equivalent of this (using while loop) is

while ( i < 6)

Not to forget that variable i has been initialized to 1.

The range of the inner iteration is, j = 1 to i + 1;

The equivalent of this (using while loop) is

while ( j < i + 1)

Also, not to forget that variable j has been initialized to 1.

The two iteration is then followed by a print statement; print('*',end='')

After the print statement has been executed, the inner loop must be close (thus was done by the statement on line 6, j = j + 1)

As seen in the for loop statements, the outer loop was closed immediately after the inner loop;

The same is done in the while loop statement (on line 7)

The closure of the inner loop is followed by another print statement on line 7 (i = i + 1)

Both loops were followed by a print statement on line 8.

The output of both program is

*

*

*

*

*

3 0
3 years ago
Other questions:
  • Which service enables administrators to execute a command on remote computers using windows powershell or the windows remote she
    6·1 answer
  • What invention changed the nature of communication and commerce in the first half of the nineteenth century?
    13·2 answers
  • Which function would you use to make sure all names are prepared for a mailing label?
    10·2 answers
  • Within a table, the intersection of a row and a column creates a(n) ____.
    13·1 answer
  • Which of the following software programs provides for e-mail communication?
    5·1 answer
  • Samuel loves playing the violin, but he feels embarrassed after a classmate posts a video on a social networking site making fun
    6·2 answers
  • To find out where a particular command is taken from, you can use the _____________ command.
    14·1 answer
  • To print factorial of any<br>input number <br>QBASIC​
    6·1 answer
  • Ria and her team ....................... they will win. *
    8·1 answer
  • Copying materials from a source text without using is<br> considered plagiarism<br> ?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!