mrScarlett

==

Aug 31st, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. /**
  2. Copy and paste this code into a new class called 'cat', run it, does it work as it should?
  3. */
  4. import java.util.Scanner;
  5. public class cat
  6. {
  7. public static void main (String[] args){
  8. Scanner userInput=new Scanner(System.in);
  9. System.out.println("Enter an animal");
  10. String animal= userInput.next();
  11. if (animal=="cat"){
  12. System.out.println("you are a cat");
  13. }
  14. else{
  15. System.out.println("you are NOT a cat");
  16.  
  17. }
  18.  
  19. }
  20. }
Add Comment
Please, Sign In to add comment