Question

In: Computer Science

Input from console 3 double numbers, compare these 3 numbers and display them from small to...

Input from console 3 double numbers, compare these 3 numbers and display them from small to great.

In Java Please

Solutions

Expert Solution

Source Code:

Output:

Code in text format (See above images of code for indentation):

import java.util.*;

/*class definition*/

public class Main

{

    /*main method*/

    public static void main(String[] args)

    {

        /*Scanner object to read data from the user*/

        Scanner read=new Scanner(System.in);

        double a,b,c;

        /*read 3 values from console*/

        System.out.print("Enter the value of a: ");

        a=read.nextDouble();

        System.out.print("Enter the value of b: ");

        b=read.nextDouble();

        System.out.print("Enter the value of c: ");

        c=read.nextDouble();

        /*compare and print small to greatest*/

        if(a<b&&a<c)

        {

            System.out.print(a+" ");

            if(b<c)

            {

                System.out.print(b+" ");

                System.out.print(c+" ");

            }

            else

            {

                System.out.print(c+" ");

                System.out.print(b+" ");

            }

        }

        /*order b a c or b c a prints*/

        else if(b<a&&b<c)

        {

            System.out.print(b+" ");

            if(a<c)

            {

                System.out.print(a+" ");

                System.out.print(c+" ");

            }

            else

            {

                System.out.print(c+" ");

                System.out.print(a+" ");

            }

        }

        /*ordere c a b or c b a*/

        else

        {

            System.out.print(c+" ");

            if(a<b)

            {

                System.out.print(a+" ");

                System.out.print(b+" ");

            }

            else

            {

                System.out.print(b+" ");

                System.out.print(a+" ");

            }

        }

    }

}


Related Solutions

Prompt user to enter 2 integer numbers from console, compare and display these 2 numbers from...
Prompt user to enter 2 integer numbers from console, compare and display these 2 numbers from small to great. This is required to be done in MIPS assembly language.
Input 10 integers and display the following: a. the sum of even numbers. b. the sum...
Input 10 integers and display the following: a. the sum of even numbers. b. the sum of odd numbers. c. the largest integer d. the smallest integer e. the total count of even numbers f. the total count of odd numbers. Using C++ program with for loop..
Write an algorithm (flowchart) for the following problems: Take ten different numbers as input and display...
Write an algorithm (flowchart) for the following problems: Take ten different numbers as input and display the sum of there squares (SS). Example: let the inputs are: 3, 0, -1, 0, 9, -5, 6, 0, 2, 1 then 157 is displayed, because: SS=32+02+(-1)2+02+92+(-5)2+62+02+22+12=157
in Java, write a program that takes an input of 4 numbers and splits them into...
in Java, write a program that takes an input of 4 numbers and splits them into 4 separate lines. EXAMPLE: so if input is 1994 the output should be 1 9 9 4
4. Prompt user to enter a double number from console. Round this number so it will...
4. Prompt user to enter a double number from console. Round this number so it will keep 2 places after the decimal point. Display new number. For example, number 12.3579 will round to 12.36; number 12.4321 will round to 12.43 This is meant to be written in Java 14.0
(JAVA) Create a program that takes in 15 numbers in sorted order from the console and...
(JAVA) Create a program that takes in 15 numbers in sorted order from the console and stores them in a 1D array of size 15. Next, prompt the user for a number to search for in the array (target). Then, print the array. Next, search the array using a linear search – printing out each of the indices (or “indexes”) that are being examined until the algorithm either finds the target or doesn’t. Then, do the same thing for a...
A program is required to compare three numbers to see if any of them is equal...
A program is required to compare three numbers to see if any of them is equal to the product of the other two. The program will take three integers, between 1 and 100 inclusive. The program should output one of the following strings: a = b * c b = a * c c = a * b No number is the product of the others You are given the following test data and an incomplete and error-filled program. Test...
Write a program that accept an integer input from the user and display the least number...
Write a program that accept an integer input from the user and display the least number of combinations of 500s, 100s, 50s, 20s, 10s, 5s, and 1s. Test your solution using this samples] a. Input: 250 Output: 1x200s, 1x50s b. Input: 1127 Output: 5x200s, 1x100s, 1x20s, 1x5s, 2x1s c. Input: 1127 Output: 5x200s, 1x100s, 1x20s, 1x5s, 2x1s d. Input: 19 Output: 1x10s, 1x5s, 4x1s ​[Hints] o Use division to determine the number of occurrence of each element (i.e. 200, 100)...
Write a java code that allows the user to input any word/name from the console (10...
Write a java code that allows the user to input any word/name from the console (10 words/names only) and then sorts and alphabetizes them into an array without using predefined methods (.compareTo(), or any sorter functions) and then print out the results. you must have three methods that can: Compare multiple strings Swap elements Sort and alphabetize string ***REMEMBER DO NOT USE ANY PRE-DEFINED METHODS*** Example of how the code should work: Enter names/words (10 only): "james, john, alex, aaron,...
Write a program which accepts a sequence of comma-separated numbers from console and generate a list...
Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34, 67, 55, 33, 12, 98. Then, the output should be: ['34', '67', '55', '33', '12', '98'] and ('34',67', '55', '33', '12', '98').
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT