Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main (String[] args)
- {
- char charUsed;
- String stringUsed;
- int choice = -1;
- boolean inProgress = true;
- Scanner inputStream = new Scanner(System.in);
- while(inProgress == true)
- {
- charUsed = getKeyCharacter();
- stringUsed = getString();
- System.out.println("Pick one of the three things (1-3) :");
- System.out.println("1. The target string with the key character replaced by dollar-signs.");
- System.out.println("2. The target string with the key character removed.");
- System.out.println("3. The number of occurrences of the key character (case sensitive) in the target string.");
- while(choice < 0 || choice > 4)
- choice = inputStream.nextInt();
- if(choice == 1)
- {
- System.out.println("You chose to replace the dollar character with dollar-signs");
- choice = -1;
- }
- else if(choice == 2)
- {
- System.out.println("You chose to remove the character.");
- choice = -1;
- }
- else
- {
- System.out.println("You chose count the number of occurrences of the character");
- choice = -1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement