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]
3 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]3 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
I'll give u 16 points answer thisss
irga5000 [103]
Big hero six was the greatest kid movie ever invented like there is no question about that I love that movie
5 0
2 years ago
Need help this is for my technology class. We are doing a city research paper but it’s the rough draft and I’m doing la. But I c
serious [3.7K]
One business is " Backwards Beekeepers," Your welcome. >,<
5 0
3 years ago
Read 2 more answers
Which design principle will help me add an element of interest in my poster by avoiding confusion and monotony?
Rasek [7]

Answer:

You could add pictures to help convey the viewer, while capturing their attention. It will provide great interest as well.

Explanation:

Me being a viewer, I love to see pictures. They help explain the topic, while keeping my attention.

7 0
3 years ago
Microwave transmits information between network nodes using
tekilochka [14]

Answer:

Towers and satellite.

Explanation:

Electromagnetic waves is a propagating medium used in all communications device to transmit data (messages) from the device of the sender to the device of the receiver.

Generally, the most commonly used electromagnetic wave technology in telecommunications is radio waves.

Radio waves can be defined as an electromagnetic wave that has its frequency ranging from 30 GHz to 300 GHz and its wavelength between 1mm and 3000m. Therefore, radio waves are a series of repetitive valleys and peaks that are typically characterized of having the longest wavelength in the electromagnetic spectrum.

Basically, as a result of radio waves having long wavelengths, they are mainly used in long-distance communications such as the carriage and transmission of data.

The distance from one peak to the next peak is called wavelength. This distance is also equal to the distance from one trough of a wave to another.

Also, microwave is a form of radio waves which typically has short wavelengths and frequency ranging from 300 MHz and 300 GHz.

Hence, microwave transmits information between network nodes using towers and satellite.

7 0
2 years ago
Read 2 more answers
How are you today? I'm fine
sweet-ann [11.9K]

Answer:

no this is partick.

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • 7.12 LAB: Contains the character
    12·2 answers
  • A(n ____ is anything about which data are to be collected and stored.
    8·1 answer
  • Which of the following best describes compounds.
    12·1 answer
  • Minerals can form deep inside Earth’s crust by
    13·1 answer
  • A system is composed of four parts, J, K, L, and M. All four must function for the system to function. The four component reliab
    6·1 answer
  • My phone takes forever to load the ads, does anyone else have this problem? Is there a way to fix it? I’ve tried getting another
    12·2 answers
  • An apple, potato, and onion all taste the same if you eat them with your nose plugged
    9·2 answers
  • Why does the peot use a simular pharase at the beggining of each stanza
    8·1 answer
  • 1. Separate valid and invalid variables:
    9·1 answer
  • Question 3 of 10<br> What was the fly in the ointment of Timmy's friendship with Rollo?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!