Ask Question
30 October, 11:41

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);

+1
Answers (1)
  1. 30 October, 13:14
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers