View Single Post
Join Date: Nov 2008
Posts: 8
Reputation: beginner21 is an unknown quantity at this point 
Solved Threads: 0
beginner21 beginner21 is offline Offline
Newbie Poster

pls help w/ this

 
0
  #1
Nov 30th, 2008
hi everyone,
can someone help me w/ this
here is my code:
  1. import java.io.*;
  2. public class Num2
  3. {
  4. public static void main(String[]args)throws IOException
  5. {
  6. BufferedReader a=new BufferedReader(new InputStreamReader(System.in));
  7. String comma;
  8. int r1, c1, r2, c2;
  9. int[][]cards;
  10. cards=new int[4][4];
  11. for(int r=0; r<4; r++)
  12. {
  13. for(int c=0; c<4; c++)
  14. {
  15. cards[r][c]=(int) (Math.random() * 8 + 1);
  16. System.out.print(cards[r][c]);
  17. }
  18. System.out.print("\n");
  19. }
  20. for (int r=0; r<4; r++)
  21. {
  22. for (int c=0; c<4; c++)
  23. {
  24. System.out.print("*");
  25. }
  26. System.out.print("\n");
  27. }
  28. System.out.print("\nPlease insert the first card row and column seperated by a comma.");
  29. r1=Integer.parseInt(a.readLine());
  30. comma=a.readLine();
  31. c1=Integer.parseInt(a.readLine());
  32. System.out.print("\nPlease insert the second card row and column seperated by a comma.");
  33. r2=Integer.parseInt(a.readLine());
  34. comma=a.readLine();
  35. c2=Integer.parseInt(a.readLine());
  36. //reveal
  37. for(int r=0; r<4; r++)
  38. {
  39. for (int c=0; c<4; c++)
  40. {
  41. if((r==r1)&&(c==c1))
  42. {
  43. System.out.print(cards[r][c]);
  44. }
  45. else if((r==r2)&&(c==c2))
  46. {
  47. System.out.print(cards[r][c]);
  48. }
  49. else
  50. {
  51. System.out.print("*");
  52. }
  53. System.out.println();
  54. }
  55. //match?
  56. if (cards[r1][c1]==cards[r2][c2])
  57. {
  58. }
  59. else
  60. {
  61. }
  62. //this pushes the next board onto a blank screen
  63. for (int b=0; b<=20; b++)
  64. System.out.println();
  65. }
  66. }
  67. }
my problem here is once i entered the row and columns,there is nothing happens..pls help,
here's the error...
  1. ---------- Capture Output ----------
  2. > "C:\jdk1.3.0_02\bin\java.exe" Num2
  3. 5373
  4. 7563
  5. 5732
  6. 8555
  7. ****
  8. ****
  9. ****
  10. ****
  11.  
  12. Please insert the first card row and column seperated by a comma.1,2
  13. java.lang.NumberFormatException:
  14. at java.lang.Integer.parseInt(Integer.java:426)
  15. at java.lang.Integer.parseInt(Integer.java:454)
  16. at Num2.main(Num2.java:29)
  17. Exception in thread "main"
and also how to hide the values of the cards,
i mean only the * can only be seen,
once the row and the column is inputted,
the values will only show,
pls help w/ my program
Reply With Quote