Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class fitnes {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int visitors = Integer.parseInt(scanner.nextLine());
- int countBack = 0;
- int countChest = 0;
- int countLegs = 0;
- int countAbs = 0;
- int countProteinshake = 0;
- int countProteinbar = 0;
- for (int i = 0; i < visitors; i++) {
- String word = scanner.nextLine();
- switch (word){
- case "Back":
- countBack++;
- break;
- case "Chest":
- countChest++;
- break;
- case "Legs":
- countLegs++;
- break;
- case "Abs":
- countAbs++;
- break;
- case "Protein shake":
- countProteinshake++;
- break;
- case "Protein bar":
- countProteinbar++;
- break;
- }
- }
- int peopleTraining = countAbs + countBack + countChest + countLegs;
- int visit = countProteinbar + countProteinshake;
- double percenttraining = peopleTraining * 1.0 / visitors * 100;
- double persentvisit = visit * 1.0 / visitors * 100;
- System.out.printf("%d - back%n", countBack);
- System.out.printf("%d - chest%n", countChest);
- System.out.printf("%d - legs%n", countLegs);
- System.out.printf("%d - abs%n", countAbs);
- System.out.printf("%d - protein shake%n", countProteinshake);
- System.out.printf("%d - protein bar%n", countProteinbar);
- System.out.printf("%.2f%% - work out %n", percenttraining);
- System.out.printf("%.2f%% - protein", persentvisit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment