Guest User

Untitled

a guest
Jan 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.*;
  2. public class Lab08{
  3. public static int readData(int[] x){
  4. Scanner input = new Scanner(System.in);
  5. int i; // declare i outside the for loop so it’s in scope later
  6. System.out.print("Enter from 1 up to " + x.length + " integers; ");
  7. System.out.println("end with -999");
  8.  
  9. for (i = 0; i < x.length; i++)
  10. { System.out.print("Enter next integer value: "); // optional prompt
  11. x[i] = input.nextInt();
  12. if (x[i] == -999) break; // quit when sentinel value entered
  13. }
  14. // at this point the value in variable i is the number of inputs entered
  15. if (i == 0)
  16. { System.out.println("Error: you must enter at least 1 element");
  17. System.exit(0); }
  18.  
  19. return i;
  20. }
  21. public static int[] getLargestAndSmallest(int[] list, int size) {
  22.  
  23. }
  24. public static void main(String[] args){
  25. int[] elements = new int[100];
  26. int count=readData(elements);
  27. int[] values = getLargestAndSmallest(elements, count);
  28. for (i=0;i<values.length;i++)
  29. {System.out.println(
Add Comment
Please, Sign In to add comment