Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package worldseries;
  7. import java.util.*;
  8. import java.io.*;
  9. /**
  10. *
  11. * @author keyof
  12. */
  13. public class WorldSeries {
  14.  
  15.  
  16.  
  17.  
  18. public static void main(String[] args) throws IOException
  19. {
  20.  
  21.  
  22. firstPart();
  23. System.out.println("###################");
  24. secondPart();
  25.  
  26.  
  27. }
  28.  
  29. static void firstPart()throws IOException{
  30. String line;
  31. File file = new File("Teams.txt");
  32. Scanner in = new Scanner(file);
  33.  
  34. while (in.hasNext())
  35. {
  36. line= in.nextLine();
  37. System.out.println(line);
  38. }
  39. in.close();
  40. }
  41.  
  42.  
  43.  
  44.  
  45. static void secondPart() throws IOException {
  46. File file = new File("WorldSeriesWinners.txt");
  47. Scanner in = new Scanner(file);
  48. Scanner userIn = new Scanner(System.in);
  49. String line;
  50. int output = 0;
  51. String input;
  52. System.out.println( "Enter a team's name");
  53. input = userIn.nextLine();
  54. System.out.println("Finding World Series Championship Count For: " +input);
  55.  
  56. while (in.hasNext())
  57. {
  58. line = in.nextLine();
  59.  
  60. if (line.equals(input)) {
  61. output++;
  62. }
  63.  
  64. }
  65. in.close();
  66. System.out.println("Win Count For " + input + "Win Count For " + input + " : " + output );
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement