Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int land = 0;
- int air = 0;
- int water = 0;
- do
- {
- String stdInput = stdin.next();
- if (stdInput.equalsIgnoreCase("land"))
- {
- land++;
- }else if (stdInput.equalsIgnoreCase("air"))
- {
- air++;
- }else if (stdInput.equalsIgnoreCase("water"))
- {
- water++;
- }
- }while (stdin.equalsIgnoreCase("xxxxx") == false); // I think the issue is here, I just dont't know why it doesn't work this way
- System.out.println("land: " + land);
- System.out.println("air: " + air);
- System.out.println("water: " + water);
- String stdInput = null;
- do {
- stdInput = stdin.next();
- //your ifs....
- } while (!stdInput.equalsIgnoreCase("xxxxx"));
- String stdInput = null;
- do {
- stdInput = stdin.next();
- // rest of code the same
- } while (!stdInput.equalsIgnoreCase("xxxxx"));
- for (String stdInput = stdin.next(); !stdInput.equalsIgnoreCase("xxxxx"); stdInput = stdin.next()) {
- // rest of code the same
- }
- int land = 0;
- int air = 0;
- int water = 0;
- String word = "";
- while(!(word.equals("xxxxx"))) {
- word = stdin.next();
- if(word.equals("land")) {
- land++;
- }else if(word.equals("air")) {
- air++;
- }else if(word.equals("water")) {
- water++;
- }
- }
- System.out.println("land:" + land);
- System.out.println("air:" + air);
- System.out.println("water:" + water);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement