Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oktobar2zad2;
- import java.io.*;
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[] args) throws IOException
- {
- BufferedReader inputStream = null;
- Scanner sc = new Scanner(System.in);
- try
- {
- String unos,izdat;
- int suma = 0, tiket=0;
- while(true)
- {
- inputStream = new BufferedReader(new FileReader("kladionica.txt"));
- unos = sc.nextLine();
- if(unos.equalsIgnoreCase("kraj")) break;
- while((izdat=inputStream.readLine())!=null)
- {
- if(unos.equalsIgnoreCase(izdat)) suma++;
- }
- tiket++;
- }
- if(tiket<4) System.out.println("Vaš tiket je nevažeći.");
- else
- {
- if (tiket == suma) System.out.println("Vaš tiket je dobitni.");
- else System.out.println("Vaš tiket nije dobitni.");
- System.out.println("Imate "+suma+"/"+tiket+" pogodaka.");
- }
- }
- finally
- {
- if(inputStream!=null) inputStream.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement