Question

In the Java language
media%2Fb5f%2Fb5f725f2-5e66-441b-95f2-90

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SortThree.java

import java.util.Scanner;


public class SortThree {

  
   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       System.out.print("Please enter first number: ");
       double v1 = scan.nextDouble();
       System.out.print("Please enter second number: ");
       double v2 = scan.nextDouble();
       System.out.print("Please enter third number: ");
       double v3 = scan.nextDouble();
       sort(v1,v2,v3);
   }
   public static void sort(double v1, double v2, double v3){
       if ((v1 >= v2 && v1 >= v3))
{
if(v2 >= v3)
{
System.out.print(v3 + " " + v2 + " " + v1);
}
else
System.out.print(v2 + " " + v3 + " " + v1);
}
else if ((v2 >= v1 && v2 >= v3))
{
if(v1 >= v3)
{
System.out.print(v3 + " " + v1 + " " + v2);
}
else
{
System.out.print(v1 + " " + v3 + " " + v2);
}
}
else if ((v3 >= v1 && v3 >= v2))
{
if(v1 >= v2)
{
System.out.print(v2 + " " + v1 + " " + v3);
}
else
System.out.print(v1 + " " + v2 + " " + v3);
}


   }

}

Output:

Please enter first number: 4
Please enter second number: 9
Please enter third number: 2.5
2.5 4.0 9.0

Please enter first number: 5.7
Please enter second number: 5.7
Please enter third number: 5.7
5.7 5.7 5.7

Add a comment
Know the answer?
Add Answer to:
In the Java language APCS Sorting Numbers Lab Write a program that reads in 3 floating-point...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • LANGUAGE: JAVA Sorting an array: 2. Write a program that asks the user for 5 numbers...

    LANGUAGE: JAVA Sorting an array: 2. Write a program that asks the user for 5 numbers and stores them in an array called data. Then call a method that accepts the array as an argument, sorts the array in ascending order and prints out the original AND sorted array (Hint: The method does not return anything in this case, so it should be set to void).

  • Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the ...

    Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the merge sort algorithm. The basic steps of merge sort are: 1) divide a collection of items into two lists of equal size, 2) use merge sort to separately sort each of the two lists, and 3) combine the two sorted lists into one sorted list. Of course, if the collection of items is just asingle item then merge sort doesn’t need to perform the three steps,...

  • In Python 3, Write a program that reads a set of floating-point values. Ask the user...

    In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...

  • In Java* ​​​​​​​ Write a program that reads an arbitrary number of 20 integers that are...

    In Java* ​​​​​​​ Write a program that reads an arbitrary number of 20 integers that are in the range 0 to 100 inclusive. The program will ask a user to re-enter an integer if the user inputs a number outside of that range. The inputted integers must then be stored in a single dimensional array of size 20. Please create 3 methods: 1. Write a method public static int countEven(int[] inputArray) The method counts how many even numbers are in...

  • 3. Write a Java method (called sumOfSquares) that reads in a sequence of integer numbers using...

    3. Write a Java method (called sumOfSquares) that reads in a sequence of integer numbers using a Scanner object. As each integer is read, the method displays that integer. The method also accumulates the sum of the squares of the integers and displays the sum when all integers are read. The method reads integers until a negative integer is read. The negative integer should not be display or added to the sum of squares. The method will not return a...

  • 4. the algorithims for sorting numbers should be managed in separate functions (e.g., sortAscending() and sortDescending())...

    4. the algorithims for sorting numbers should be managed in separate functions (e.g., sortAscending() and sortDescending()) Create a Kotlin console program that satisfies the following 1. The program prompts a user to enter a number that is used to create an array with the number of elements. 2. The program asks the user to enter a series of numbers, and the numbers are to be entered and stored in the array 3. The program asks the user to select the...

  • Write a complete JAVA program to do the following program. The main program calls a method...

    Write a complete JAVA program to do the following program. The main program calls a method to read in (from an input file) a set of people's three-digit ID numbers and their donations to a charity (hint: use parallel arrays)Then the main program calls a method to sort the ID numbers into numerical order, being sure to carry along the corresponding donations. The main program then calls a method to print the sorted 1ists in tabular form, giving both ID...

  • Create a JAVA program that in two numbers from user input, the program then does the...

    Create a JAVA program that in two numbers from user input, the program then does the following arithmetic calculations. The program will run in ascending order if the first number is small and in descending order of the first number is bigger. The program then alternates between addition(ODD) and subtraction(EVEN) depending on the previous number see examples below   [15] Sample run 1: Enter two numbers: -3 2 Output: The following arithmetic calculations were performed : Arithmetic operations = (-3) +...

  • Create a program that will determine the even number(s) from a list of numbers. Your program...

    Create a program that will determine the even number(s) from a list of numbers. Your program should create and call a function FindEven that accepts a list of numbers and returns a list of only the even numbers in sorted order. Note that the original list is given in the starter code. def body(): numberlist = [1, 1000, 5, -3, 2, 16 # Write your code here and notice level # Do NOT include: if __name__ == been provided for...

  • Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves...

    Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves searching and sorting an array of integers. Write a java application that initializes an array with the following numbers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Then display the unsorted values. This is required output #1 of 6 for this program. 2) Using a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT