HarrJ

Day 07 recap 1

Nov 15th, 2023
1,073
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Day07A {
  4.     public static void main(String[] args) {
  5.         // theme farm animals
  6.         Scanner sc = new Scanner(System.in);
  7.         String animalName;
  8.        
  9.         System.out.print("Enter an animal name: ");
  10.         animalName = sc.nextLine();
  11.        
  12.         //scenario, depending of what user enter an info about the animal will be shown
  13.         if (animalName.equals("cow")) {
  14.             System.out.println("Cows gives milk");
  15.         } else if (animalName.equals("carabao")) {
  16.             System.out.println("Carabao helps with the fields");
  17.         } else if (animalName.equals("_")) {
  18.             System.out.println("__");
  19.         } else {
  20.             System.out.println("You typed: " + animalName);
  21.             System.out.println("animal is not on list. Please try again");
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment