Solution: Workout Volume Tracker

The main() function is a workout tracker that lets the user select a muscle group, enter how many days they trained it during the week, log their daily sets, and get feedback on their training volume.

  • Uses a while (true) loop to repeatedly show a workout menu until the user chooses to exit.

  • Displays six options (Chest, Back, Shoulders, Arms, Legs, Exit) and stores the user’s input in choice.

  • If the user enters 6, the program prints "Exiting tracker. Goodbye!" and ends the loop with break.

  • A switch statement assigns a muscle name (like "Chest" or "Back") based on the user’s selection. If the input is invalid, it prints "Invalid option. Try again." and restarts the loop.

  • Asks the user how many days they trained that muscle (days). If the number is not between 1 and 7, it prints a warning and restarts the loop.

  • Uses a for loop to collect the number of sets performed for each training day, adding them up in totalSets.

  • After collecting all data, it prints the total sets for that muscle group.

  • Uses if-else statements to give feedback:

    • More than 20 sets → "Overtraining!"

    • 10–20 sets → "Good volume."

    • Fewer than 10 sets → "Low volume."

  • The loop then repeats, allowing the user to track another muscle or exit the program.

Solution: Workout Volume Tracker

The main() function is a workout tracker that lets the user select a muscle group, enter how many days they trained it during the week, log their daily sets, and get feedback on their training volume.

  • Uses a while (true) loop to repeatedly show a workout menu until the user chooses to exit.

  • Displays six options (Chest, Back, Shoulders, Arms, Legs, Exit) and stores the user’s input in choice.

  • If the user enters 6, the program prints "Exiting tracker. Goodbye!" and ends the loop with break.

  • A switch statement assigns a muscle name (like "Chest" or "Back") based on the user’s selection. If the input is invalid, it prints "Invalid option. Try again." and restarts the loop.

  • Asks the user how many days they trained that muscle (days). If the number is not between 1 and 7, it prints a warning and restarts the loop.

  • Uses a for loop to collect the number of sets performed for each training day, adding them up in totalSets.

  • After collecting all data, it prints the total sets for that muscle group.

  • Uses if-else statements to give feedback:

    • More than 20 sets → "Overtraining!"

    • 10–20 sets → "Good volume."

    • Fewer than 10 sets → "Low volume."

  • The loop then repeats, allowing the user to track another muscle or exit the program.