LiFiUnit6.java Provide a driver class that has the following items: Creates an i
ID: 3691178 • Letter: L
Question
LiFiUnit6.java
Provide a driver class that has the following items:
Creates an instance of the FiFiWorkout.java class.
Gets input for first name.
Create a constant to hold the desired duration of workout. Set it to 30.
Create a constant to hold the desired number of reps. Set it to 20.
Use a looping structure to get input until either “M’ or ‘W’ are entered. Accept M or m and W or w. Use the string class to convert it to upper case.
Use a switch structure to work with either the ‘M’ or ‘W’.
Get input for the machine name such as “elliptical” or “treadmill”.
Get the duration in minutes of the workout performed.
Get input for the weight in integer.
Get input for the number of reps performed.
After the input has been accepted above:
If the workout duration or reps are equal to or above the desired, then output “Good Job” as shown in the sample, including the duration, reps, machine, desired duration, or desired reps. See sample for exact output.
60%
LiFiWorkout.java
Provide a workout class to hold instance variables as required by the driver.
Include accessor and mutator methods for each even if they aren’t required by the driver.
Sample output is provided below. Be sure to mimic it exactly except for values entered.
LiFiUnit6.java
Provide a driver class that has the following items:
Creates an instance of the FiFiWorkout.java class.
Gets input for first name.
Create a constant to hold the desired duration of workout. Set it to 30.
Create a constant to hold the desired number of reps. Set it to 20.
Use a looping structure to get input until either “M’ or ‘W’ are entered. Accept M or m and W or w. Use the string class to convert it to upper case.
Use a switch structure to work with either the ‘M’ or ‘W’.
If M or Machine is selected:Get input for the machine name such as “elliptical” or “treadmill”.
Get the duration in minutes of the workout performed.
If W or Weights is selected:Get input for the weight in integer.
Get input for the number of reps performed.
After the input has been accepted above:
If the workout duration or reps are equal to or above the desired, then output “Good Job” as shown in the sample, including the duration, reps, machine, desired duration, or desired reps. See sample for exact output.
60%
LiFiWorkout.java
Provide a workout class to hold instance variables as required by the driver.
Include accessor and mutator methods for each even if they aren’t required by the driver.
Sample output is provided below. Be sure to mimic it exactly except for values entered.
Explanation / Answer
package com.dq.thematrix.main.java.jetty.nginx;
import java.util.Scanner;
public class FiFiWorkout {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String firstName=sc.nextLine();
int duration=30;
int duration_desired=30;
int reps_desired=20;
int reps=20;
int wieght=0;
String machineName=null;
String input=sc.nextLine();
do
{
System.out.println("Keep trying. until you dont provide M or W");
input=sc.nextLine();
}while(!(input.equalsIgnoreCase("M") || input.equalsIgnoreCase("W")));
input=input.toUpperCase();
machineName=sc.nextLine();
switch(input)
{
case "M":
duration=sc.nextInt();
break;
case "W":
wieght=sc.nextInt();
reps=sc.nextInt();
break;
}
if(duration>=duration_desired || reps>=reps_desired)
{
System.out.println("Good Job "+firstName);
System.out.println(machineName);
System.out.println(reps);
System.out.println(wieght);
System.out.println(duration);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.