# TCS Off Campus Coding Question

## TCS Off Campus Problem

This question was Asked in TCS Off Campus Recruitment 2022 for 30 minutes section. The complete solution is writeen in java.

##### Question:

A middle ware developer is working on a tank design. He has got two tanks one with hot water and another with cold water. He has given with certain time T. Both the tanks are connected with a pipe. For every 1 minute the temperature of hotter tank decreases by 1 degree calicoes and colder tanks temperature increases by 2 degree calicoes. In given time if equilibrium is not achieved by equalising temperature between two tanks the pipe bursts. Write a program to check weather pipe bursts or not.

Input:

Example 1:

TH=10

TC=6

T=2;

OUTPUT:

YES

Explanation:

Higher temperature of hotter tank is 10 and lower temperature of colder tank is 6. Time given is 6 minutes and as depicted in problem the temperature of the hotter (higher) tank decreases by 1 unit (degree celcious), temperature of colder (lower) tank increases by 2 units (degree celcious).

After 1 minute , T=1

TH=9

TC=8

Again after 1 minute T=0

TH=8

TC=10

So at the end (when T=0) if we compare both the temperatures, they are not equal so the pipe is going to burst, Return “YES” in this case.

Example 2:

TH=10

TC=7

T=1

OUTPUT

NO

After 1 minute T=0

TH=9

TC=9

So as we can see both the temperatures are same so pipe will not going to burst, in this case we need to return “No”.

#### Complete JAVA Code for Above Problem

```import java.util.*;
import java.util.Scanner;

public class problem10 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("Enter the temprature of hotter tank:" );

// Reading the Hotter tank temperature from user

int TH=sc.nextInt();
System.out.println("Enter the temprature of colder tank:" );

// Reading the colder tank temperature from user

int TC=sc.nextInt();
System.out.println("Enter the time:" );
int T=sc.nextInt();

for (int i=1;i&lt;=T;i++)
{
TH=TH-1;
TC=TC+2;
}
if(TH==TC)
{
System.out.println("No");
}
else
{
System.out.println("Yes");
}
}
}```

Watch the video for more Explanation

Thanks for visiting our blog, we have a lot of other off campus problems with solution click here to visit