Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Lab08{
- public static int readData(int[] x){
- Scanner input = new Scanner(System.in);
- int i; // declare i outside the for loop so itβs in scope later
- System.out.print("Enter from 1 up to " + x.length + " integers; ");
- System.out.println("end with -999");
- for (i = 0; i < x.length; i++)
- { System.out.print("Enter next integer value: "); // optional prompt
- x[i] = input.nextInt();
- if (x[i] == -999) break; // quit when sentinel value entered
- }
- // at this point the value in variable i is the number of inputs entered
- if (i == 0)
- { System.out.println("Error: you must enter at least 1 element");
- System.exit(0); }
- return i;
- }
- public static int[] getLargestAndSmallest(int[] list, int size) {
- }
- public static void main(String[] args){
- int[] elements = new int[100];
- int count=readData(elements);
- int[] values = getLargestAndSmallest(elements, count);
- for (i=0;i<values.length;i++)
- {System.out.println(
Add Comment
Please, Sign In to add comment