Advertisement
Guest User

Untitled

a guest
May 4th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. public static void main (String[] args)
  2. {
  3. char charUsed;
  4. String stringUsed;
  5. int choice = -1;
  6. boolean inProgress = true;
  7. Scanner inputStream = new Scanner(System.in);
  8. while(inProgress == true)
  9. {
  10. charUsed = getKeyCharacter();
  11. stringUsed = getString();
  12. System.out.println("Pick one of the three things (1-3) :");
  13. System.out.println("1. The target string with the key character replaced by dollar-signs.");
  14. System.out.println("2. The target string with the key character removed.");
  15. System.out.println("3. The number of occurrences of the key character (case sensitive) in the target string.");
  16. while(choice < 0 || choice > 4)
  17. choice = inputStream.nextInt();
  18. if(choice == 1)
  19. {
  20. System.out.println("You chose to replace the dollar character with dollar-signs");
  21. choice = -1;
  22. }
  23. else if(choice == 2)
  24. {
  25. System.out.println("You chose to remove the character.");
  26. choice = -1;
  27. }
  28. else
  29. {
  30. System.out.println("You chose count the number of occurrences of the character");
  31. choice = -1;
  32. }
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement