# TCS NQT Previous Year Solve | Slot 1 (IV) | Codewindow.in #### Solution: In java

``````import java.util.*;
import java.lang.*;
import java.io.*;

class Question
{
public static void main (String[] args) throws Exception
{
Scanner sc = new Scanner(System.in);
int x, T1=0, T2=0, T3=0, count=1;
double A1, A2, A3;
while(count =1 &amp;&amp; x &lt;= 100) {
if(count % 3 == 1)
T1 += x;
else if(count % 3 == 2)
T2 += x;
else
T3 += x;
}
count++;
}
A1 = Math.round(T1/3);
A2 = Math.round(T2/3);
A3 = Math.round(T3/3);

if(A1 &lt;= 70 &amp;&amp; A2 &lt;= 70 &amp;&amp; A3 = A2 &amp;&amp; A1 &gt;= A3)
System.out.println("Trainee Number: 1");
if(A2 &gt;= A1 &amp;&amp; A2 &gt;= A3)
System.out.println("Trainee Number: 2");
if(A3 &gt;= A1 &amp;&amp; A3 &gt;= A2)
System.out.println("Trainee Number: 3");
}
}
}``````

#### Solution: In java

``````import java.util.*;
import java.lang.*;
import java.io.*;

class Question
{
public static void main (String[] args) throws Exception
{
Scanner sc = new Scanner(System.in);
int n = 10;
int k = sc.nextInt();
if(k &lt;= 0) {
System.out.println(&quot;INVALID INPUT&quot;);
System.out.println(&quot;NUMBER OF CANDIES AVAILABLE: &quot; + n);
}
else {
System.out.println(&quot;NUMBER OF CANDIES SOLD: &quot; + k);
System.out.println(&quot;NUMBER OF CANDIES AVAILABLE: &quot; + (n-k));
}
}
}``````