Advertisement
Kendred

Fortune Cookie Fixer

Mar 5th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. mport java.io.File;
  2. import java.util.Scanner;
  3.  
  4. public class Program {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. File f = new File ("File.txt");
  9.  
  10. try {
  11. Scanner sc = new Scanner(f);
  12.  
  13. while(sc.hasNextLine()) {
  14.  
  15. String fortune = sc.nextLine();
  16.  
  17. if(fortune.charAt(fortune.length() -1) == '.') {
  18.  
  19. System.out.println(fortune);
  20.  
  21.  
  22. }
  23. else {
  24. System.out.println(fortune+("."));
  25. }
  26. }
  27. }
  28. catch (Exception e) {
  29. System.out.println (":(");
  30.  
  31. }
  32.  
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement