From Deitel, Do exercise 11.9 (page 563), as well as the "Replace"
exercise given below.
Filenames should be
public static String replace(String oldStr, String newStr, String str)You will need to place the MyInput.java file in the directory with your code when you compile (the same MyInput class that we used in the first few assignments). To test your replace method, use the following main() method (include it in the file that you submit):
public static void main(String[] args) { String str, sub, rep; System.out.println("Programming Exercise: 'Substring Replacing'"); System.out.print("Input initial string: "); str = MyInput.readString(); System.out.print("Input substring to be replaced: "); sub = MyInput.readString(); System.out.print("Replace with? "); rep = MyInput.readString(); System.out.println("The initial string is '" + str + "'"); System.out.println("The new string is '" + replace(sub,rep,str) + "'"); }
Programming Exercise: 'Sentences' Any boy jumped to the dog. Some dog skipped from the town. The town skipped over the car. A dog drove under a dog. The girl ran from the boy. The boy drove over a dog. A boy ran from any boy. Any boy walked on a boy. The boy jumped over one town. The girl ran to any town. Some boy jumped over any dog. The town jumped from one dog. The boy drove from the car. A girl ran over one boy. A boy walked on one car. Any dog drove on the boy. Any car drove to one dog. The town walked under one girl. One girl ran to some dog. A town ran over some boy.
Programming Exercise: 'Substring Replacing' Input initial string: The quick brown fox jumped over the quick dog Input substring to be replaced: quick Replace with? hot The initial string is 'The quick brown fox jumped over the quick dog' The new string is 'The hot brown fox jumped over the hot dog' Programming Exercise: 'Substring Replacing' Input initial string: Concatenate the bobcat with the catapult Input substring to be replaced: cat Replace with? bird The initial string is 'Concatenate the bobcat with the catapult' The new string is 'Conbirdenate the bobbird with the birdapult'
E-mail this jar file to me (myers@cs.fsu.edu) by the due date. Your e-mail subject should be HW6-SUBMIT. Include your name and section in the e-mail body. Please only submit ONCE, unless you make a mistake and need to correct it (before the due date) -- and minimize this. Only the last submission will be graded.