Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. package oktobar2zad2;
  2. import java.io.*;
  3. import java.util.Scanner;
  4. public class Main
  5. {
  6.  public static void main(String[] args) throws IOException
  7.  {
  8.  BufferedReader inputStream = null;
  9.  Scanner sc = new Scanner(System.in);
  10.  try
  11.  {
  12.  String unos,izdat;
  13.  int suma = 0, tiket=0;
  14.  while(true)
  15.  {
  16.  inputStream = new BufferedReader(new FileReader("kladionica.txt"));
  17.  unos = sc.nextLine();
  18.  if(unos.equalsIgnoreCase("kraj")) break;
  19.  while((izdat=inputStream.readLine())!=null)
  20.  {
  21.  if(unos.equalsIgnoreCase(izdat)) suma++;
  22.  }
  23.  tiket++;
  24.  }
  25.  if(tiket<4) System.out.println("Vaš tiket je nevažeći.");
  26.  else
  27.  {
  28.  if (tiket == suma) System.out.println("Vaš tiket je dobitni.");
  29.  else System.out.println("Vaš tiket nije dobitni.");
  30.  System.out.println("Imate "+suma+"/"+tiket+" pogodaka.");
  31.  }
  32.  }
  33.  finally
  34.  {
  35.  if(inputStream!=null) inputStream.close();
  36.  }
  37.  }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement