Ask Question
20 January, 21:12

Create a program to determine the largest number out of 15 numbers entered (numbers entered one at a time). This should be done in a function using this prototype:

double larger (double x, double y);

+3
Answers (1)
  1. 21 January, 01:00
    0
    Output:-

    Enter number:

    2

    Enter number:

    1

    Enter number:

    4

    Enter number:

    3

    Enter number:

    5

    Enter number:

    7

    Enter number:

    6

    Enter number:

    8

    Enter number:

    9

    Enter number:

    11

    Enter number:

    10

    Enter number:

    12

    Enter number:

    14

    Enter number:

    13

    Enter number:

    15

    Largest number: 15.0

    Explanation:

    Below is a java program to determine the largest number out of 15 numbers entered: -

    import java. util. Scanner;

    public class Largest {

    double larger (double x, double y) {

    if (x>y)

    return x;

    else

    return y;

    }

    double findLargest () {

    double y;

    double greatest=0.0;

    Scanner s=new Scanner (System. in);

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

    System. out. println ("Enter number: ");

    y=s. nextDouble ();

    greatest=larger (greatest, y);

    }

    return greatest;

    }

    public static void main (String[] args) {

    Largest l=new Largest ();

    System. out. println ("Largest number: "+l. findLargest ());

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Create a program to determine the largest number out of 15 numbers entered (numbers entered one at a time). This should be done in a ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers