Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public static void main(String[] args) throws ParseException, IOException {
  2.  
  3. BufferedReader br = new BufferedReader(new FileReader("primes.csv"));
  4. String line = null;
  5. Hashtable<String, String> map = new Hashtable<String, String>(100);
  6.  
  7. while((line = br.readLine()) != null){
  8. String str[] = line.split(",");
  9.  
  10. map.put(str[0], str[1]);
  11. }
  12. br.close();
  13. System.out.println(map);
  14.  
  15. int k;
  16.  
  17. k = Integer.parseInt(JOptionPane.showInputDialog(f,"Enter an integer k whee"
  18. + " 3 < k < 1229: "));
  19.  
  20. while (k <= 3 || k >= 1229){
  21. k = Integer.parseInt(JOptionPane.showInputDialog(f,"Sorry try again: "));
  22. }
  23.  
  24. JOptionPane.showMessageDialog(f, "The "+ k +"th prime number is " + map.get(k));
  25.  
  26. }
  27.  
  28. String str[] = line.split(",");
  29. ...
  30. map.put(str[0], str[1]);
  31. ...
  32. int k;
  33. ...
  34. map.get(k);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement