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
A Cisco Catalyst switch has been added to support the use of multiple VLANs as part of an enterprise network. The network techni
Ostrovityanka [42]

Answer:

The technician should delete the startup configuration and the "vlan.dat" file residing in the flash memory of the newly added switch and lastly, he should reboot the switch.

Explanation:

In this scenario, a Cisco Catalyst switch has been added to support the use of multiple virtual local area networks (VLANs) as part of an enterprise network. The network technician finds it necessary to clear all virtual local area network (VLAN) information from the switch in order to incorporate a new network design. To accomplish this task successfully, the technician should delete the startup configuration and the "vlan.dat" file residing in the flash memory of the newly added switch and lastly, he should reboot the switch. The VLAN informations are stored in a file with the name "vlan.dat" residing in the flash memory of the switch.

However, in order to delete the startup configuration he would be required to login as an administrator, so as to have all privileges.

<em>Also, the essence of deleting the startup configuration and the "vlan.dat" is to avoid any conflict in the network. </em>

8 0
3 years ago
Given the variables isfulltimestudent and age, write an expression that evaluates to true if age is less than 19 or isfulltimest
Pani-rosa [81]
Which language is this in?

if (age<19||isfulltimestudent==true)
    return true;
6 0
2 years ago
I'm using assembly language. This is my assignment. I kinda confused about how to write code for this assignment. Can anyone exp
Brut [27]

Answer:

oid changeCase (char char_array[], int array_size ) {

__asm{

   mov eax, char_array;    

   mov edi, 0;

readArray:

   cmp edi, array_size;

   jge exit;

   mov ebx, edi;          

   shl ebx, 2;

   mov cl, [eax + ebx];    

check:

   //working on it

   cmp cl, 0x41;      

   jl next_indx;

   cmp cl, 0x7A;      

   jg next_indx;

   cmp cl, 'a';

   jl convert_down;

   jge convert_up;

convert_down:

   or cl, 0x20;        //make it lowercase

   jmp write;

convert_up:

   and cl, 0x20;      

   jmp write;

write:

   mov byte ptr [eax + ebx], cl    

next_indx:

   inc edi;

exit:

   cmp edi, array_size;

   jl readArray;

mov char_array, eax;

}

}

Explanation:

  • Move char_array to eax as it is base image .
  • Use ebx as offset .
  • Use ecx as the storage register .
  • check if cl is <= than ASCII value 65 (A) .
6 0
3 years ago
g Create your own data file consisting of integer, double or String values. Create your own unique Java application to read all
Jlenok [28]

Answer:

See explaination

Explanation:

//ReadFile.java

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class ReadFile

{

public static void main(String[] args)

{

int elementsCount=0;

//Create a File class object

File file=null;

Scanner fileScanner=null;

String fileName="sample.txt";

try

{

//Create an instance of File class

file=new File(fileName);

//create a scanner class object

fileScanner=new Scanner(file);

//read file elements until end of file

while (fileScanner.hasNext())

{

double value=fileScanner.nextInt();

elementsCount++;

}

//print smallest value

System.out.println(elementsCount+" data values are read");

}

//Catch the exception if file not found

catch (FileNotFoundException e)

{

System.out.println("File Not Found");

}

}

}

Sample output:

sample.txt

10

20

30

40

50

output:

5 data values are read

5 0
2 years ago
Lisa is setting up her audio equipment for her recording. She has plugged in her microphone and headphones in the audio interfac
Jlenok [28]
Output is my best guess.
7 0
3 years ago
Other questions:
  • The number of credits awarded for the CLEP exam is determined by__<br> Help pls!
    15·1 answer
  • WILL MARK BRAINLIEST HELP
    8·2 answers
  • The times per second an audio file is converted from analog to digital is the ______. audio file format bandwidth sample rate wa
    5·2 answers
  • Can y’all help me with these questions ?
    5·1 answer
  • Given the function definition below, what is the effect of thecall:
    7·2 answers
  • Which of the following is a category of social media?
    8·2 answers
  • What kind of printer is used with multipart forms such as those with point of sale machines?A) dot-matrixB) daisy-wheelC) inkjet
    5·1 answer
  • A user calls to report that she is experiencing intermittent problems while accessing the wireless network form her laptop compu
    9·1 answer
  • Although designed to support remote dial-in access to a corporate network, what service below is commonly used with 802.1x port
    12·1 answer
  • How many 2/8 pound patties can she make from 7/8 of a pound of hamburger
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!