I am trying to make a program that censors the word "dang" with a "#!". My main method passes in a String sentence.
public static String deleteDang(String sentence)
/* pre: receives the sentence to be censored
post: returns the censored sentence*/
{
while(((sentence.toLowerCase()).contains("dang")))
{
sentence = (sentence.toLowerCase()).replace("dang", "#!");
}
return sentence;
}
I want it to be work so that I can enter something such as "DANG ApplE" and get the output "!# ApplE". When I attempt to run this, it outputs "!# apple" if I input "dang apple", but when I put in "DANG Apple", I have an infinite output of "DANG Apple". What am I doing wrong?
If possible, I would like to this without the use of .replaceAll
I am trying to make a program that censors the word "dang" with a "#!". My main method passes in a String sentence.
public static String deleteDang(String sentence)
/* pre: receives the sentence to be censored
post: returns the censored sentence*/
{
while(((sentence.toLowerCase()).contains("dang")))
{
sentence = sentence.replace("dang", "#!");
}
return sentence;
}
I want it to be work so that I can enter something such as "DANG ApplE" and get the output "!# ApplE". When I attempt to run this, it outputs "!# apple" if I input "dang apple", but when I put in "DANG Apple", I have an infinite output of "DANG Apple". What am I doing wrong?
If possible, I would like to this without the use of .replaceAll
I am trying to make a program that censors the word "dang" with a "#!". My main method passes in a String sentence.
public static String deleteDang(String sentence)
/* pre: receives the sentence to be censored
post: returns the censored sentence*/
{
while(((sentence.toLowerCase()).contains("dang")))
{
sentence = (sentence.toLowerCase()).replace("dang", "#!");
}
return sentence;
}
I want it to be work so that I can enter something such as "DANG ApplE" and get the output "!# ApplE". When I attempt to run this, it outputs "!# apple" if I input "dang apple", but when I put in "DANG Apple", I have an infinite output of "DANG Apple". What am I doing wrong?
If possible, I would like to this without the use of .replaceAll
I am trying to make a program that censors the word "dang" with a "#!". My main method passes in a String sentence.
public static String deleteDang(String sentence)
/* pre: receives the sentence to be censored
post: returns the censored sentence*/
{
while(((sentence.toLowerCase()).contains("dang")))
{
sentence = sentence.replace("dang", "#!");
}
return sentence;
}
I want it to be work so that I can enter something such as "DANG ApplE" and get the output "!# ApplE". When I attempt to run this, it outputs "!# apple" if I input "dang apple", but when I put in "DANG Apple", I have an infinite output of "DANG Apple". What am I doing wrong?
If possible, I would like to this without the use of .replaceAll
I am trying to make a program that censors the word "dang" with a "#!". My main method passes in a String sentence.
public static String deleteDang(String sentence)
/* pre: receives the sentence to be censored
post: returns the censored sentence*/
{
while(((sentence.toLowerCase()).contains("dang")))
{
sentence = sentence.replace("dang", "#!");
}
return sentence;
}
I want it to be work so that I can enter something such as "DANG ApplE" and get the output "!# ApplE". When I attempt to run this, it outputs "!# apple" if I input "dang apple", but when I put in "DANG Apple", I have an infinite output of "DANG Apple". What am I doing wrong?
I am trying to make a program that censors the word "dang" with a "#!". My main method passes in a String sentence.
public static String deleteDang(String sentence)
/* pre: receives the sentence to be censored
post: returns the censored sentence*/
{
while(((sentence.toLowerCase()).contains("dang")))
{
sentence = sentence.replace("dang", "#!");
}
return sentence;
}
I want it to be work so that I can enter something such as "DANG ApplE" and get the output "!# ApplE". When I attempt to run this, it outputs "!# apple" if I input "dang apple", but when I put in "DANG Apple", I have an infinite output of "DANG Apple". What am I doing wrong?
If possible, I would like to this without the use of .replaceAll
Cannot replace with Java replace method
I am trying to make a program that censors the word "dang" with a "#!". My main method passes in a String sentence.
public static String deleteDang(String sentence)
/* pre: receives the sentence to be censored
post: returns the censored sentence*/
{
while(((sentence.toLowerCase()).contains("dang")))
{
sentence = sentence.replace("dang", "#!");
}
return sentence;
}
I want it to be work so that I can enter something such as "DANG ApplE" and get the output "!# ApplE". When I attempt to run this, it outputs "!# apple" if I input "dang apple", but when I put in "DANG Apple", I have an infinite output of "DANG Apple". What am I doing wrong?