Create a class with the following methods:
a)int largest(int a,int b)which finds the largest among two numbers
b)void call() to input 10 numbers and using the above function find the largest among 5 integers
Pls solve this Java program completely
Answers
Answered by
0
Answer:
I don't understand this question so sorry
Answered by
2
Answer:
import java.util.*;
class largest
{
public static int largest(int a, int b)
{
if(a>b)
return a;
else if(b>a)
return b;
else
SOPln("Error!");
}
public static void call ()
{
Scanner sc = new Scanner(System.in)
int n, i, l;
SOPln("Enter ten numbers:");
for(i=1;i<=10;i++)
{
n=sc.nextInt();
l=largest(n);
SOPln("Largest of"+n+"="+l);
}
}
}
Explanation:
Creation of a class through methods.
Similar questions