Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programming Use Object Oriented Programming, Classes, methods, and arrays.

ID: 3842689 • Letter: J

Question

Java Programming

Use Object Oriented Programming, Classes, methods, and arrays. Create an array that holds 10 random integers between 1 - 100. Create the array inside the class. Create a method that will fill the array with 10 random integers. Create a method that will return the largest integer in the array. Create a method that will return the smallest integer in the array. Use method naming conventions. Main should only be used to execute methods created in the class. Output smallest and largest integer to text file. Create Header Row. Whiteboard/Pseudocode Solution (Attach Photo of Text File, Source Code, and Output Below.) Advance implementation use an array list to solve problem.

Explanation / Answer


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Random;
class RandomInteger
{
public static void main(String args[])
{
int[] numb = new int[10];
System.out.println(" Random Numbers are : ");
for(int i=0; i<numb.length; i++)
{
numb[i] = (int)(Math.random() * 100+1);
System.out.print(" " + numb[i] + " ");
}
int max = 0, min = numb[0];
for(int i=0; i<10; i++)
{
if(numb[i] > max)
{
max = numb[i];
}
if(numb[i] < min)
{
min = numb[i];
}
}
System.out.println(" Largest in the array is: " +max);
System.out.println(" Smallest in the array is: " +min);
}
}


OUTPUT


Random Numbers are :


   20    40    35    11    52    17    5    38    18    99


Largest in the array is: 99


Smallest in the array is: 5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote