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
____________ facilitates the processes that help an organization function by applying information and communication technologies
artcher [175]

Answer: (C) E-business

Explanation:

 The E-business basically facilitates the various company and organizations a large portion of its exchanges by using the Internet utilizing the majority of innovation and the correspondence interfaces.

E-business is basically known as electronic business  and it conduct various type of business forms on the web.

The various e-business procedures incorporate purchasing and selling the various types of the items, supplies and administrations that adjusting client and preparing installments. It is mainly help in sharing the information and data in the system.

 

3 0
3 years ago
Name an analog quantity other than temperature and sound
liq [111]
I know that this might be wrong but is it light?
6 0
3 years ago
Judy forgot where she saved a certain file on her computer. Therefor, she searches for all files with a jpg file extension. Whic
Keith_Richards [23]
What are these files anyways
6 0
3 years ago
Read 2 more answers
A location in memory used for storing data and given a name in a computer program is called a because the data in the location c
Gekata [30.6K]
Variable

----------------------------------
6 0
4 years ago
PLEASE HELP ME I WILL GIVE BRAINIEST AND 40 POINTSPython Project Worksheet
Paha777 [63]

Answer:

i can only give you pseudocode my fren

Explanation:

# information about me

def main():

MyName =  “malaki”

print(myName)

myInfo = “I was born in wichita, Kansas U.S. I live in japan. I love hotdogs.”

print(myInfo)

main()

sorry if this did not help :( i tried

6 0
3 years ago
Other questions:
  • Which disk drive type contains a magnetic HDD with onboard flash memory serving as a non-volatile cache?
    6·1 answer
  • Will an email sent from a phone say it was sent from your phone
    5·2 answers
  • Ryan is the operations manager for a national financial company. His company is in the process of creating a customer handbook.
    13·1 answer
  • Which best describes the differences between a resume and a CV?
    13·2 answers
  • What are the characteristics of good blogs?
    8·1 answer
  • I prefer a job where I am praise for good performance or I am accountable for results
    13·1 answer
  • Which activity is the best example of a negative habit that may result from
    12·1 answer
  • Ajdbksjdnksnsd helppp​
    11·1 answer
  • Describe risk avoidance. Name three common methods of risk avoidance.
    5·1 answer
  • A large retail company hires several new joiners and would like to incorporate Virtual Reality (VR) into their onboarding proces
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!