Instructions A Set up the compiler on your workstation B Wri
Instructions:
A. Set up the compiler on your workstation.
B. Write, compile, and run a Java program that: *
(1) uses a single line comment to document your source code with your name and section
number. This should be the very first line of your program,
(2) uses a printin statement to print your name and section number as the first line of your
output,
(3) define a recursive functiomnamed \"largest* that will return the largest number in an
array. Use {23, 35, 67, 76, 34} to initialize the array.
(4) calls \"largest\" to return the largest number in the following array.
C. Diagram (i.e. illustrate with a picture) your program completely.
Solution
Here is the code for your problem
//Name:xxx Section: yyy
class Largest {
      static int i=0, max=-999;//static variables of class
   
 static int largest(int arr[])
 
 {
   if(i < arr.length)
    {
       if( max < arr[i] )
       {
          max = arr[i];
       }
       i++;
       largest(arr);
    }
 return max;
 }
public static void main(String [ ] args){
 
 int arr[]={23, 35, 67, 76, 34};
String name=\"xxx\";
String section=\"yyy\";
System.out.println(\"Name:\"+name+\"\ Section:\"+section);
int large=largest(arr);
System.out.println(\"Largest element in array is \"+large);
}
}
output:
sh-4.3$ javac Largest.java
sh-4.3$ java Largest
Name:xxx
Section:yyy
Largest element in array is 76
sh-4.3$


