Guest User

Untitled

a guest
May 22nd, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Scanner;
  4.  
  5. public class Problem
  6. {
  7. public static void main(String[] args)
  8. {
  9. Scanner keyboard = new Scanner(System.in);
  10. ArrayList<String> wordList = new ArrayList<String>();
  11.  
  12. int choice = 1;
  13. while(choice > 0)
  14. {
  15. System.out.println(" ");
  16. System.out.println("What would you like to do?");
  17. System.out.println("1) Enter a new list of words.");
  18. System.out.println("2) Find First and Last Alphabetical, and Longest and Shortest.");
  19. System.out.println("3) Show the current list of words.");
  20. System.out.println("0) Exit the Program.");
  21. System.out.print("> ");
  22.  
  23. choice = Integer.parseInt(keyboard.nextLine());
  24.  
  25. if(choice < 0 || choice > 3)
  26. {
  27. System.out.println("Invalid Command!");
  28. System.out.println(" ");
  29. continue;
  30. }
  31. else if(choice == 2)
  32. {
  33.  
  34. }
  35. else if(choice == 3)
  36. {
  37. displayList(wordList);
  38. }
  39. else if(choice == 1)
  40. {
  41. wordList = getNewArrayFrom(keyboard);
  42. System.out.print(" ");
  43. }
  44. }
  45. System.out.print("Goodbye!");
  46. }
  47. public static ArrayList<String> getNewArrayFrom(Scanner input)
  48. {
  49. System.out.println("How many words would you like to enter?");
  50. System.out.print("> ");
  51. System.out.print(" ");
  52. int ArrayLength = Integer.parseInt(input.nextLine());
  53. ArrayList<String> wordList = new ArrayList<String>();
  54. System.out.print("Enter each of the words.");
  55. for(int i = 0; i < ArrayLength; i++)
  56. {
  57. System.out.println(" ");
  58. System.out.println((i+1) + "> ");
  59. wordList.add(input.nextLine());
  60. }
  61. return wordList;
  62. }
  63. public static void displayList(ArrayList<String> wordList)
  64. {
  65. System.out.print("You entered: ");
  66. System.out.println(" ");
  67. for(int i = 0; i < wordList.size(); i++);
  68. {
  69. System.out.print("" + wordList);
  70. }
  71. }
  72. public int firstAlphabetical(ArrayList<String> wordList)
  73. {
  74.  
  75. for(int i = 0; i < wordList.size(); i++)
  76. {
  77.  
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment