Question
NEED HELP I NEED THE Method thoroughly tested in a JUnit test file with at least three assert methods CODE /////////////////////////////////////////////// import java.util.*; public class
NEED HELP I NEED THE Method thoroughly tested in a JUnit test file with at least three assert methods
CODE
///////////////////////////////////////////////
import java.util.*;
public class WorkoutPlanner {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Welcome to WorkoutPlanner! Let's create your workout plan.");
// get user input
System.out.print("Enter the name of the exercise: ");
String exerciseName = input.nextLine();
System.out.print("Enter the number of sets: ");
int numSets = input.nextInt();
System.out.print("Enter the number of reps per set: ");
int numReps = input.nextInt();
System.out.print("Enter the day you want to schedule this workout (1-7, where 1 is Monday): ");
int workoutDay = input.nextInt();
// modify user input
String formattedExerciseName = exerciseName.substring(0,1).toUpperCase() + exerciseName.substring(1).toLowerCase();
// if statement
if (numReps <= 0 || numSets <= 0) {
System.out.println("Invalid input! Please enter a positive integer for sets and reps.");
System.exit(0);
}
// arithmetic operation
int totalReps = numSets * numReps;
// loop
for (int i = 1; i <= numSets; i++) {
System.out.println("Set " + i + " - Do " + numReps + " reps of " + formattedExerciseName);
}
// method
displayWorkoutPlan(workoutDay, formattedExerciseName, numSets, numReps);
System.out.println("Your total number of reps for this exercise is " + totalReps);
}
// method definition
public static void displayWorkoutPlan(int day, String exercise, int sets, int reps) {
System.out.println("Your workout plan for day " + day + " is: ");
System.out.println(sets + " sets of " + reps + " reps of " + exercise);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started