Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import java.util.*;
  2. public class Assignment11C
  3. {
  4. public static void main(String[]args)
  5. {
  6. int i,repeat=1;
  7. String sentence,s,dummy;
  8. Scanner input=new Scanner(System.in);
  9.  
  10. while(repeat==1)
  11. {
  12. System.out.println("Enter your sentence");
  13. sentence=input.nextLine();
  14. for(i=0;i<sentence.length();i++)
  15. {
  16. sentence=sentence.replaceAll("foo","oof");
  17. }
  18. System.out.println("Here is the updated sentence");
  19. System.out.println(sentence);
  20. System.out.println("Do you want to repeat Y(1) or N(2)");
  21. repeat=input.nextInt();
  22. dummy=input.nextLine();
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement