Advertisement
AnindyaBiswas

apple_enum

Jun 1st, 2022
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. enum apple
  4. {McIntosh, Cosmic_Crisp, Red_Delicious, Golden_Delicious, Exit_Apples}
  5.  
  6. public class apple_enum {
  7.  
  8.     public static void main(String[] args)
  9.     {
  10.         Scanner sc = new Scanner(System.in);
  11.         while(true)
  12.         {
  13.             int c=1;
  14.             System.out.println("The list of apples are:\n");
  15.             for(apple i : apple.values())
  16.                 System.out.println(c++ + ". " +i);
  17.        
  18.             System.out.print("\nEnter your choice : ");
  19.             int choice = sc.nextInt();
  20.             apple a = apple.values()[choice - 1];
  21.             switch(a)
  22.             {
  23.                 case McIntosh:
  24.                     System.out.println("\n\n" + a + "\nThey are mild with a nice balance between sweet and tart. It’s not as firm as other varieties, which is why it’s best raw or chopped up into a salad or slaw.\n");
  25.                     break;
  26.                 case Cosmic_Crisp:
  27.                     System.out.println("\n\n"+ a + "\nThis apple is the remarkable result of 20 years of study and research by Washington State University’s world-class tree fruit breeding program. Classically bred and grown in Washington State\n");
  28.                     break;
  29.                 case Red_Delicious:
  30.                     System.out.println("\n\n"+ a + "\nThey have a super mild, simple flavor that doesn’t tend to stand out when cooked into dishes or used in pie. So, they’re best eaten as a snack all on their own.\n");
  31.                     break;
  32.                 case Golden_Delicious:
  33.                     System.out.println("\n\n"+ a + "\nUnrelated to the Red Delicious apple, Golden Delicious apples are soft with a thin skin. This is one variety you want to eat or freeze as soon as possible. \n");
  34.                     break;
  35.                 case Exit_Apples:
  36.                     return;
  37.                 default : continue;
  38.             }
  39.         }
  40.     }
  41.    
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement