# Help me in solving LBJ18 problem

### My code

``````// Update the code below to solve this problem
import java.util.Scanner;

class Codechef
{
public static void main (String[] args)
{

for(int i=0; i<t; i++)
{
int numBreaks = X / 3;

// Calculate total time without breaks
int totalTimeWithoutBreaks = X * Y;

// Calculate total break time
int totalBreakTime = numBreaks * Z;

// Calculate total time for completing the game
int totalTime = totalTimeWithoutBreaks + totalBreakTime;

// Output the result
System.out.println(totalTime);
}
}
}
``````

Learning course: Solve Programming problems using Java
Problem Link: CodeChef: Practical coding for everyone

@sahil_2701
like for x is a multiple of 3 u have to subtract 1 from numBreaks because there no point of taking a break after the completion of all levels .

Can u send the code as well.
Actually what you told me I was do that but it will give me again a wrong answer…

@sahil_2701
Here is the code :-
Hope u will get it.
import java.util.Scanner;

class Codechef
{
public static void main (String[] args)
{

``````	int t = read.nextInt();
for(int i=0; i<t; i++)
{
int numBreaks = X / 3;
if(X%3==0)
{
numBreaks--;
}
// Calculate total time without breaks
int totalTimeWithoutBreaks = X * Y;

// Calculate total break time
int totalBreakTime = numBreaks * Z;

// Calculate total time for completing the game
int totalTime = totalTimeWithoutBreaks + totalBreakTime;

// Output the result
System.out.println(totalTime);
}
}
``````

}