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
lisabon 2012 [21]
3 years ago
7

Two Smallest (20 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. java TwoSmallest 17.0 23.0 5.0 1.1 6.9 0.3 0.3 1.1 java TwoSmallest 1.0 35.0 2.0 1.1 6.9 0.3 0.3 6.7 0.3 0.3
Computers and Technology
1 answer:
Ivan3 years ago
4 0

Answer:

Written in Java

import java.util.*;

public class Main {

   public static void main(String args[]) {

     int n;

     Scanner input = new Scanner(System.in);

     n = input.nextInt();

     double nums []= new double [n];

     for (int i=0; i<n;i++)

     {

         nums[i] = input.nextDouble();

     }

     

     Arrays.sort(nums);

     System.out.println("The two smallest are: ");

     for (int i=0; i<2;i++)

     {

         System.out.println(nums[i]);

     }

   }

}

Explanation:

This line declares number of input

     int n;

This line calls the Scanner function

     Scanner input = new Scanner(System.in);

This line gets input from user

     n = input.nextInt();

This line declares an array of n elements

     double nums []= new double [n];

The following iteration gets input into the array

     for (int i=0; i<n;i++)

     {

         nums[i] = input.nextDouble();

     }

This line sorts the array

     Arrays.sort(nums);

The following iteration prints the two smallest

     System.out.println("The two smallest are: ");

     for (int i=0; i<2;i++)

     {

         System.out.println(nums[i]);

     }

You might be interested in
Briefly explain how Riboflavin deficiency lead to disease state.​
4vir4ik [10]

Answer:

Severe riboflavin deficiency can impair the metabolism of other nutrients, especially other B vitamins, through diminished levels of flavin coenzymes [3]. Anemia and cataracts can develop if riboflavin deficiency is severe and prolonged [1]. The earlier changes associated with riboflavin deficiency are easily reversed.

6 0
3 years ago
Can 7Cs help to develope an effective document?
zvonat [6]

Answer:

i dont know k srry

Explanation:

8 0
3 years ago
Which item cannot be inserted into a header or footer of a document? automatic page numbers tables with columns and rows picture
lidiya [134]
Pictures shapes clipart
8 0
3 years ago
Read 2 more answers
What is the difference between soft copy output devices and hard copy output devices​
Alecsey [184]

the output printed on the paper is called hardcopy output. some examples are printer and plotter.

the output produced on display screen and audio sound is called soft copy output. some examples are moniter and speaker.

3 0
3 years ago
1. In Windows Vista, which process allows you to display two documents side by side?
alexandr1967 [171]
The answer is D: click the windows icon button, choose control panel, select appearance and personalization, choose the taskbar, and select side by side
3 0
3 years ago
Read 2 more answers
Other questions:
  • What are three methods of sustainable farming and describe each.
    9·1 answer
  • Define the missing method. licenseNum is created as: (100000 * customID) + licenseYear. Sample output: Dog license: 77702014
    14·1 answer
  • 1. _____ can’t be rewritten by the computer in which it’s installed, but it has the advantage of being very _____.
    6·1 answer
  • The set of instructions that tells a computer
    12·2 answers
  • A group of students want to create an educational online game for computer laboratory in their school which type of network will
    6·1 answer
  • Power point presentation make use of pages known as
    9·2 answers
  • SXXSSSSSSSSSZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
    14·1 answer
  • What was the biggest challenge you faced in getting to where you are today and how did you overcome it? Peer counseling
    5·1 answer
  • Fill in the blank
    10·1 answer
  • When a number gets assigned to a variable that already has a value __________. the new number overwrites the previous value at t
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!