Programming Basics Online Example Exam 1 - Fitness Center
Здравейте,
Не мога да разбера защо получавам само 60/100 на тази задача. Някой може ли да каже къде е грешката, моля?
Благодаря!
https://alpha.judge.softuni.org/contests/programming-basics-online-example-exam-1/1538/practice#10
Ето го и моят код: import java.util.Scanner; public class FitnessCenter { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int qty = Integer.parseInt(scanner.nextLine()); int back = 0; int chest = 0; int legs = 0; int abs = 0; int shake = 0; int bar = 0; for (int i = 1; i <= qty; i++) { String sport = scanner.nextLine(); switch (sport) { case "Back": back++; break; case "Chest": chest++; break; case "Legs": legs++; break; case "Abs": abs++; break; case "Protein shake": shake++; break; case "Protein bar": bar++; break; } } if (back > 0) { System.out.printf("%d - back%n", back); } if (chest > 0) { System.out.printf("%d - chest%n", chest); } if (legs > 0) { System.out.printf("%d - legs%n", legs); } if (abs > 0) { System.out.printf("%d - abs%n", abs); } if (shake > 0) { System.out.printf("%d - protein shake%n", shake); } if (bar > 0) { System.out.printf("%d - protein bar%n", bar); } int workoutCount = back + chest + legs + abs; int proteinCount = shake + bar; double workoutPercentage = (workoutCount * 100.0) / qty; double proteinPercentage = (proteinCount * 100.0) / qty; System.out.printf("%.2f%% - work out%n", workoutPercentage); System.out.printf("%.2f%% - protein", proteinPercentage); } }