The following program is supposed to read input numbers from

The following program is supposed to read input numbers from the user and print those numbers. It should also find the smallest value and mark it in the output. Complete the program by adding your code.

import java.util.Scanner;

/** This program reads a sequence of values and prints them, marking the smallest value.

Sample Output:

Please enter values, Q to quit:

80

34.5

115

44.5

Q

List of all values and the smallest:

80

34.5 <==smallest value

115

44.5

*/ public class SmallestInArray{

public static void main(String[] args){

final int LENGTH = 100;

// Write your code: declare an array

int currentSize = 0;

// Read inputs

System.out.println(\"Please enter values, Q to quit:\");

Scanner scan = new Scanner(System.in);

while (scan.hasNextDouble() && currentSize < values.length){

// Write your code }

// Find the smallest value double smallest = values[0];

for (int i = 1; i < currentSize; i++){

// Write your code }

// Print all values, marking the smallest

System.out.println(“List of all values and the smallest:”);

for (int i = 0; i < currentSize; i++){

// Write your code

System.out.println(); }

}

}

Solution

// Print all values, marking the smallest

System.out.println(“List of all values and the smallest:”);

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

// Write your code

System.out.println(i);

if (i == smallest)

}

The following program is supposed to read input numbers from the user and print those numbers. It should also find the smallest value and mark it in the output.
The following program is supposed to read input numbers from the user and print those numbers. It should also find the smallest value and mark it in the output.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site