wxns

java_code_output

Sep 6th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1.     public int pocketNumber(int q) {
  2.  
  3.         int repeat = 0;
  4.         do {
  5.             System.out.print("Please select the number of pockets you want to work with: ");
  6.             Scanner qu = new Scanner(System.in);
  7.             int userQu = qu.nextInt();
  8.  
  9.             if (userQu > 7 || userQu < 1) {
  10.                 System.out.println("Sorry, that is not a valid number of pockets. ");
  11.                 repeat = 1;
  12.             } else {
  13.                 System.out.println("You have chosen " + userQu + " pockets to work with. ");
  14.                 return userQu;
  15.             //    break;
  16.             } // once this complete, values erased.
  17.         } while (repeat == 1);
  18.  
  19.         return q;
  20.     }  
  21.  
  22. /* Output
  23. Hello World!
  24. Here is a list of the elements contained within your array:
  25. 0. 33
  26. 1. 34
  27. 2. 35
  28. 3. 36
  29. 2
  30. You have chosen 2. 35
  31. Please select the shirt sleeve length of your garment:
  32. None
  33. Cap sleeves
  34. Short sleeves
  35. 3/4 length sleeves
  36. Long sleeves
  37. Long sleeves with holes
  38. Long sleeves
  39. You have chosen Long sleeves
  40. Please select the number of pockets you want to work with:  5
  41. You have chosen 5 pockets to work with.
  42. Please enter the pocket you want to work with:  7
  43. Sorry, we cannot work with that pocket.
  44. What properties would you like to have for this pocket?
  45. i0
  46. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
  47.     at program$topClothing.managePockets(program.java:104)
  48.     at program$topClothing.access$300(program.java:5)
  49.     at program.main(program.java:207)
  50.  
  51. Process finished with exit code 1
  52. */
Advertisement
Add Comment
Please, Sign In to add comment