Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- public class Test {
- public static void main(String[] args) throws InterruptedException {
- // Location of file to read
- File file = new File("a.txt");
- List<String> lines = new ArrayList<String>();
- try {
- Scanner scanner = new Scanner(file);
- while (scanner.hasNextLine()) {
- lines.add(scanner.nextLine());
- }
- scanner.close();
- for (int i=1 ; i < lines.size(); i+=2)
- {
- String question = lines.get(i - 1);
- String answer=lines.get(i += 1);
- String a = JOptionPane.showInputDialog("" + question);
- if (a.equals(answer)){
- Thread.sleep(10000);
- }else
- JOptionPane.showMessageDialog(null,"Please look it up");
- }
- } catch (FileNotFoundException e) {
- System.out.println("Can't find file");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement