Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. package my1darray_paulinoh;
  2. import java.io.*;
  3. import java.util.Arrays.*;
  4.  
  5. public class My1DArray_PaulinoH {
  6. BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
  7.  
  8. int num[] = new int [5];
  9. static int val, item;
  10. static String p;
  11. public int insertItem() throws IOException
  12. {
  13. System.out.print("Enter Value: ");
  14. val = Integer.parseInt(input.readLine());
  15. return val;
  16. }
  17.  
  18. /*public int findLocationInsert()
  19. {
  20.  
  21. }
  22.  
  23. public int deleteItem()
  24. {
  25.  
  26. }
  27.  
  28. public int findLocationDelete()
  29. {
  30.  
  31. }*/
  32. public static void main(String[] args) throws IOException {
  33. BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  34. My1DArray_PaulinoH arr = new My1DArray_PaulinoH();
  35.  
  36. //Options
  37. System.out.println("What would you like to be performed?");
  38. System.out.println("1.) Insert a value.\n2.) Delete a value.\n3.) Traverse array.\n4.) Exit.");
  39. System.out.println("Enter number:");
  40. p = input.readLine();
  41.  
  42.  
  43. if(null == p)
  44. System.out.println("Error. Try again.");
  45. else switch (p)
  46. {
  47. case "1":
  48. System.out.println("You picked Option 1. ");
  49. val = arr.insertItem();
  50. break;
  51. case "2":
  52. System.out.println("You picked Option 2. ");
  53. //arr.deleteItem();
  54. break;
  55. case "3":
  56. System.out.println("You picked Option 3. ");
  57. //arr.traverse();
  58. break;
  59. case "4":
  60. System.out.println("You picked Option 4. ");
  61. System.out.println("Thank you for using our service. Goodbye.");
  62. System.exit(0);
  63. default:
  64. System.out.println("Error. Try again.");
  65. break;
  66. }
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement