Advertisement
476179

switchstring

Nov 4th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package les;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Switch_Strings
  6. {
  7.  
  8. public static void main(String[] args)
  9. {
  10. //switch statment that translatwes names of the seasons in eng to span
  11.  
  12.  
  13. String season;
  14. Scanner keyboard= new Scanner(System.in);
  15. System.out.println("enter a season");
  16. season = keyboard.nextLine();
  17. season = season.toUpperCase();
  18.  
  19. switch(season)
  20. {
  21. case"WINTER":
  22. System.out.println("el invernot");
  23. break;
  24.  
  25. case "SPRING":
  26. System.out.println("la primavera");
  27. break;
  28.  
  29. case "SUMMER":
  30. System.out.println("el verano");
  31. break;
  32.  
  33. case "FALL":
  34. case "AUTUM":
  35. System.out.println("el otoio");
  36. break;
  37.  
  38. default:
  39. System.out.println("invalid choice");
  40. break;
  41. }
  42.  
  43. keyboard.close();
  44.  
  45.  
  46.  
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement