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
https://brainly.com/question/10197478#:~:text=Option%20A%20is%20the%20correct,in%20return%20of%20their%20money.
Alex17521 [72]
Thanks for free points
7 0
3 years ago
Which of the following is a good technique to use when driving in an urban environment
nadya68 [22]

Answer:

A. Passing

Explanation:

Passing is a good technique to use when driving in an urban environment .

5 0
3 years ago
Read 2 more answers
What are the 3 symbols that can’t be used when saving a document? (From Microsoft Word 2016) (pls helped me!)
Charra [1.4K]

Answer:

\, /, -

Explanation:

The three symbols are forward slash, backward slash, and the hyphen. These were allowed in previous versions of the MS Word. However, since the MS Word 2016 and a little earlier, these three symbols have been banned. And you will immediately get a message if you use these, to correct, and only then the file will be saved with that new name, and that must not have the forward or backward slash or the hyphen.

6 0
4 years ago
What is an example of static we page?
OlgaM077 [116]
I’m pretty sure it’s B I hope this help you and I’m sorry if I got it wrong
4 0
4 years ago
Does group policy management matter without a server environment?
eimsori [14]

Answer:

The group policy management is one of the policy which used in the microsoft window that basically control the server working environment in the organization. It mainly control the user account and the personal computer account.

The group policy is the centralized management and the provide the various configuration of the operating system. It also manage and control the users setting in the active directory of the management.

Therefore, the group policy management matter in the server environment.

4 0
4 years ago
Other questions:
  • Jim has entered the age of each of his classmates in cells A1 through A65 of a spreadsheet. Which function should Jim use to fin
    11·2 answers
  • You need to control the number of people who can be in an oyster bar at the same time. Groups of people can always leave the bar
    12·1 answer
  • Mitchell is assisting her teacher in a project by entering data into the spreadsheet. Which types of data can Michelle enter in
    14·2 answers
  • What is likely to happen to the economy when there’s too much money or credit circulating?
    13·1 answer
  • A student has created a Book class. The class contains variables to represent the following.An int variable called pages to repr
    11·1 answer
  • Which activity does not allow a person to perform any work while at the shop
    10·1 answer
  • Rate monotonic Analysis (RMA) is a model for predicting whether or not a system will meet its timing as well as throughput requi
    6·1 answer
  • Is an architecture where a client runs an applications provided by a server on a network
    7·1 answer
  • Sonja is writing a program to compare two numbers and print the larger number. Which of these should be used?
    6·1 answer
  • Plz help me I will mark as the brainlest I only need long answer plz help me ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!