Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. 3
  2. Ruby
  3. Diamond
  4. Sapphire
  5.  
  6. import java.util.Scanner;
  7.  
  8. public class GemStones {
  9.  
  10. private int numOfStones;
  11. private String[] gemArray;
  12.  
  13. public void solve() throws Exception{
  14.  
  15. Scanner in = new Scanner(System.in);
  16.  
  17. //Reading the integer
  18. numOfStones = Integer.parseInt(in.nextLine());
  19. //in.nextLine();
  20. System.out.println(numOfStones);
  21.  
  22.  
  23. //reading the strings
  24. for(int i=0;i<numOfStones;i++){
  25. gemArray[i] = in.nextLine();
  26. System.out.println(gemArray[i]);
  27. }
  28.  
  29.  
  30. for(int i=0;i<numOfStones;i++){
  31. System.out.println(gemArray[i]);
  32. }
  33. in.close();
  34. }
  35.  
  36.  
  37. public static void main(String[] args) throws Exception {
  38. GemStones check = new GemStones();
  39. check.solve();
  40.  
  41.  
  42. }
  43.  
  44. }
  45.  
  46. numOfStones = Integer.parseInt(in.nextLine());
  47. //in.nextLine();
  48. System.out.println(numOfStones);
  49.  
  50. //reading the strings
  51. for (int i = 0; i < numOfStones; i++) {
  52. gemArray[i] = in.nextLine();
  53. System.out.println(gemArray[i]);
  54. }
  55.  
  56. numOfStones = Integer.parseInt(in.nextLine());
  57. //in.nextLine();
  58. System.out.println(numOfStones);
  59.  
  60. // Intialise gemStones here...
  61. gemStones = new String[numOfStones];
  62.  
  63. //reading the strings
  64. for (int i = 0; i < numOfStones; i++) {
  65. gemArray[i] = in.nextLine();
  66. System.out.println(gemArray[i]);
  67. }
  68.  
  69. public void solve() throws Exception{
  70.  
  71. Scanner in = new Scanner(System.in);
  72.  
  73. //Reading the integer
  74. numOfStones = Integer.parseInt(in.nextLine());
  75. //in.nextLine();
  76. System.out.println(numOfStones);
  77.  
  78. gemArray = new String[numOfStones];
  79. //reading the strings
  80. for(int i=0;i<numOfStones;i++){
  81. gemArray[i] = in.nextLine();
  82. System.out.println(gemArray[i]);
  83. }
  84.  
  85.  
  86. for(int i=0;i<numOfStones;i++){
  87. System.out.println(gemArray[i]);
  88. }
  89. in.close();
  90. }
  91.  
  92. gemStones = new String[numOfStones];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement