Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Write a method which gets a String from the user, and returns it.
- Your method signature is :
- public static String getString()
- Write another method which checks if the word "rabbit" is in the passed String parameter.
- If the "rabbit" is present, it prints "It seems you would like to talk about rabbits".
- If "rabbit" is not present, it prints "Why don't we talk about rabbits, instead?"
- Your method signature is:
- public static void checkForRabbits(String param)
- { ...
- }
- In your main method; call getString() to get the user input. Call checkForRabbits() with the String from getString().
- */
- import java.util.*;
- public class Unit4ReviewQuestion8 {
- private static Scanner text;
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- System.out.println("What would you like to talk about?");
- text = new Scanner(System.in);
- String path = text.next();
- String Rabbit = "rabbit";
- if (path.equals(Rabbit)) {
- System.out.println("It seems you would like to talk about rabbits");
- } else {
- System.out.println("Why don't we talk about rabbits instead");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement