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
Which one of these is NOT a type of printer
rusak2 [61]

Answer:

electric

Explanation:

eletric is not a print ouo

4 0
3 years ago
Read 2 more answers
PART 2 - Exercise 2 - Programming Assignment
Oliga [24]

Suppose that a linked list is used as a data structure for the hash table, create a program that includes steps his application counts the number of phrases in documents decided on via way of means of the user #include.

<h3>What is Programming?</h3>

It is the manner of making hard and fast commands that inform a pc the way to carry out a task. Programming may be finished the usage of lots of pc programming languages, inclusive of JavaScript, Python, and C++.

  1. This application counts the quantity of phrases in documents decided on via way of means of the user.
  2. #include
  3. #include
  4. #include the usage of namespace std; //Function 1 int count(string word)go back word.size();
  5. }
  6. //Function 2
  7. int vowel(string word)> filename;
  8. //Open the {input|enter">enter file.
  9. inputfile.open(filename.c_str()); cout<<"nWord listing after format";
  10. cout<<"n____nn"; //If the file succesfully opened, process it.if (inputfile).

Read more about program :

brainly.com/question/1538272

#SPJ1

5 0
2 years ago
How do you copy from a file to another document<br>​
algol13

Answer:

you highlight it then double tap and click copy or after it is highlighted press ctrl and c together then to paste you double tap and click paste or you can press ctrl v

Explanation:

7 0
3 years ago
Read 2 more answers
PLZ HELP NEEDS TO BE ANSWERED ASAP THANK YOU
Stells [14]

In python:

lst = ([])

largest = 0

while len(lst) != 6:

   user_number = int(input("Enter a number: "))

   lst.append(user_number)

   for i in lst:

       if i > largest:

           largest = i

   print(largest)

I hope this helps

7 0
3 years ago
Which of these best describes cloud computing? A. an on-demand service that helps to access shared computing and storage resourc
Basile [38]
I think its A. an on-demand service that helps to access shared computing and storage resources from anywhere using an Internet connection
5 0
3 years ago
Other questions:
  • What protocol must be supported by routers in order to utilize remote assistance easy connect?
    10·1 answer
  • On laptops with a smart card reader installed, where is the smart card reader usually located?
    5·1 answer
  • When malicious code is planted on your computer and alters your browser's ability to find web addresses, it is known as ________
    7·2 answers
  • . Briefly describe an SQL DML statement for changing existing data in a table.
    5·1 answer
  • Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cr
    7·1 answer
  • When is the redo log buffer written to the redo log file?
    5·1 answer
  • Which of the following is an example of an access object?
    9·1 answer
  • How many clients has<br> Accenture engaged globally on blockchain?
    12·1 answer
  • This Command to insert copied text anywhere in your document
    13·2 answers
  • What is the difference between a computer’s RAM and its hard disk?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!