Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. int land = 0;
  2. int air = 0;
  3. int water = 0;
  4.  
  5. do
  6. {
  7. String stdInput = stdin.next();
  8. if (stdInput.equalsIgnoreCase("land"))
  9. {
  10. land++;
  11. }else if (stdInput.equalsIgnoreCase("air"))
  12. {
  13. air++;
  14. }else if (stdInput.equalsIgnoreCase("water"))
  15. {
  16. water++;
  17. }
  18. }while (stdin.equalsIgnoreCase("xxxxx") == false); // I think the issue is here, I just dont't know why it doesn't work this way
  19. System.out.println("land: " + land);
  20. System.out.println("air: " + air);
  21. System.out.println("water: " + water);
  22.  
  23. String stdInput = null;
  24.  
  25. do {
  26. stdInput = stdin.next();
  27.  
  28. //your ifs....
  29.  
  30. } while (!stdInput.equalsIgnoreCase("xxxxx"));
  31.  
  32. String stdInput = null;
  33. do {
  34. stdInput = stdin.next();
  35. // rest of code the same
  36. } while (!stdInput.equalsIgnoreCase("xxxxx"));
  37.  
  38. for (String stdInput = stdin.next(); !stdInput.equalsIgnoreCase("xxxxx"); stdInput = stdin.next()) {
  39. // rest of code the same
  40. }
  41.  
  42. int land = 0;
  43. int air = 0;
  44. int water = 0;
  45. String word = "";
  46. while(!(word.equals("xxxxx"))) {
  47. word = stdin.next();
  48. if(word.equals("land")) {
  49. land++;
  50. }else if(word.equals("air")) {
  51. air++;
  52. }else if(word.equals("water")) {
  53. water++;
  54. }
  55. }
  56. System.out.println("land:" + land);
  57. System.out.println("air:" + air);
  58. System.out.println("water:" + water);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement