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

Re: pls help w/ this

 
0
  #3
Nov 30th, 2008
ok,
i get it
here is my modified 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.  
  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);
  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.");
  29. r1=Integer.parseInt(a.readLine());
  30. System.out.print("\nPlease insert the first card column.");
  31. c1=Integer.parseInt(a.readLine());
  32. System.out.print("\nPlease insert the second card row.");
  33. r2=Integer.parseInt(a.readLine());
  34. System.out.print("\nPlease insert the first card column.");
  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. }
  54. //match?
  55. if (cards[r1][c1]==cards[r2][c2])
  56. {
  57. }
  58. else
  59. {
  60. }
  61. }
  62. }
  63. }
the output is this:
  1. 5446
  2. 5611
  3. 4143
  4. 4601
  5. ****
  6. ****
  7. ****
  8. ****
  9.  
  10. Please insert the first card row.1
  11.  
  12. Please insert the first card column.2
  13.  
  14. Please insert the second card row.3
  15.  
  16. Please insert the second card column.3
  17. ******1********1
how can i fix it?
Reply With Quote