dakata450

Untitled

Jul 14th, 2022
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class fitnes {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int visitors = Integer.parseInt(scanner.nextLine());
  8. int countBack = 0;
  9. int countChest = 0;
  10. int countLegs = 0;
  11. int countAbs = 0;
  12. int countProteinshake = 0;
  13. int countProteinbar = 0;
  14.  
  15. for (int i = 0; i < visitors; i++) {
  16. String word = scanner.nextLine();
  17. switch (word){
  18. case "Back":
  19. countBack++;
  20. break;
  21. case "Chest":
  22. countChest++;
  23. break;
  24. case "Legs":
  25. countLegs++;
  26. break;
  27. case "Abs":
  28. countAbs++;
  29. break;
  30. case "Protein shake":
  31. countProteinshake++;
  32. break;
  33. case "Protein bar":
  34. countProteinbar++;
  35. break;
  36. }
  37.  
  38. }
  39. int peopleTraining = countAbs + countBack + countChest + countLegs;
  40. int visit = countProteinbar + countProteinshake;
  41. double percenttraining = peopleTraining * 1.0 / visitors * 100;
  42. double persentvisit = visit * 1.0 / visitors * 100;
  43.  
  44. System.out.printf("%d - back%n", countBack);
  45. System.out.printf("%d - chest%n", countChest);
  46. System.out.printf("%d - legs%n", countLegs);
  47. System.out.printf("%d - abs%n", countAbs);
  48. System.out.printf("%d - protein shake%n", countProteinshake);
  49. System.out.printf("%d - protein bar%n", countProteinbar);
  50. System.out.printf("%.2f%% - work out %n", percenttraining);
  51. System.out.printf("%.2f%% - protein", persentvisit);
  52.  
  53. }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment