Join Regular Classroom : Visit ClassroomTech

TCS NQT Previous Year Solve | Slot 1 (IV) | Codewindow.in

TCS NQT

Coding

Question 1:

Selection of MPCS exams include a fitness test which is conducted on ground.There will be a batch of 3 trainees, appearing for a running test on track for 3 rounds. You need to record their oxygen level after every round. After trainees are finished with all rounds, calculate for each trainee his average oxygen level over the 3 rounds and select the one with the highest average oxygen level as the most fit trainee. If more than one trainee attains the same highest average level,they all need to be selected. Display the most fit
trainee(or trainers) and the highest average oxygen level.

Note:
1. The oxygen value entered should not be accepted if it is not in the range between 1 and 100.
2. If the calculated maximum average oxygen value of the trainees is below 70 then declare the trainees as unfit with meaningful message as “All trainees are unfit”
3. Average oxygen values should be rounded

Example 1:

Input Values:
95
92
95
92
90
92
90
92
90

Output Values:
Trainee Number: 1
Trainee Number ;3

Note: Input should be 9 integer values representing oxygen levels entered in order as

Round 1:
Oxygen value of trainee 1
Oxygen value of trainee 2
Oxygen value of trainee 3

Round 2:
Oxygen value of trainee 1
Oxygen value of trainee 2
Oxygen value of trainee 3

Round 3:
Oxygen value of trainee 1
Oxygen value of trainee 2
Oxygen value of trainee 3

Oxygen must be in given format as in above example. For any wrong input final output should display “INVALID INPUT”.

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 && x <= 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 <= 70 && A2 <= 70 && A3 = A2 && A1 >= A3)
		        System.out.println("Trainee Number: 1");
		    if(A2 >= A1 && A2 >= A3)
		        System.out.println("Trainee Number: 2");
		    if(A3 >= A1 && A3 >= A2)
		        System.out.println("Trainee Number: 3");
		}
	}
}

Question 2:

There is jar full of candies for sale at a mall counter. JAr has the capacity N, that is JAR can contain maximum N Candies when JAR is full. At any point of time, JAR can have M number of candies where M<=N. Candies are served to the customers. JAR is never remaining empty as when last K candidates are left,JAR is refilled with new candidates in such a way that JAR gets full. Write the code to implement above scenario. Display JAR at counter with available number of candies. Input should be number of candies one customer orders at point of time. Update the JAR after every purchase and display JAR at counter.Output should give number of candies sold and updated number of candies in JAR. If input is more than number of candies in JAR,return “INVALID INPUT”. Given, N=10, Where N is number of candies available, K<=5,Where K is number of minimum candies that must be inside JAR ever.

Example 1:
(N=10,K=<5)
Input Value
3
Output Values:
Number of Candies Sold: 3
Number of Candies available:7

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));
		}
	}
}

Warning: Undefined array key "icon" in /home/u997094728/domains/codewindow.in/public_html/wp-content/plugins/elementor/includes/widgets/icon-box.php on line 695

Warning: Undefined array key "icon" in /home/u997094728/domains/codewindow.in/public_html/wp-content/plugins/elementor/includes/widgets/icon-box.php on line 708

Warning: Undefined array key "icon" in /home/u997094728/domains/codewindow.in/public_html/wp-content/plugins/elementor/includes/widgets/icon-box.php on line 695

Warning: Undefined array key "icon" in /home/u997094728/domains/codewindow.in/public_html/wp-content/plugins/elementor/includes/widgets/icon-box.php on line 708

Also Checkout

Recent Posts
Categories
Pages