> AP Computer Science Problem Help?? Loops?!?!?

AP Computer Science Problem Help?? Loops?!?!?

Posted at: 2014-12-18 
import java.util.Scanner;

public class MyString {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter string: ");

String str = sc.nextLine();

// remove whitespace

while(str.indexOf(" ") >= 0){

str = str.replace(" ", "");

}

// remove e's

str = str.replaceAll("e","");

str = str.replaceAll("E","");

//replace vowels

str = str.replaceAll("[AEIOU]", "!");

str = str.replaceAll("[aeiou]", "!");

// backwards

str = new StringBuilder(str).reverse().toString();

System.out.println(str);

}

}

import java.util.regex.*;

public class Program {

public static void main(String[] args) {

String value = "thequickbrownfoxjumpoverthelazydog";

String result = value.replaceAll("[aeiou]", "!");

System.out.println(result); // output: th!q!!ckbr!wnf!xj!mp!v!rth!l!zyd!g

}

}

1. Write a loop that asks a user to input a string, then prints it out (a) excluding spaces (b) excluding the letter e or E (c) replacing vowels with ! (d) backwards.

I have gotten every part of the problem but part C. I do not know how to get java to exclude more than one character from a string. Help would be great!