Washing Machine : Fuzzy System

TCS Coding Question 1 Slot 2

TCS Coding Question Day 1 Slot 2

A washing machine works on the principle of Fuzzy System, the weight of clothes put inside it for washing is uncertain But based on weight measured by sensors, it decides time and water level which can be changed by menus given on the machine control area.  

For low level water, the time estimate is 25 minutes, where approximately weight is between 2000 grams or any nonzero positive number below that.

For medium level water, the time estimate is 35 minutes, where approximately weight is between 2001 grams and 4000 grams.

For high level water, the time estimate is 45 minutes, where approximately weight is above 4000 grams.

Assume the capacity of machine is maximum 7000 grams

Where approximately weight is zero, time estimate is 0 minutes.

Write a function which takes a numeric weight in the range [0,7000] as input and produces estimated time as output is: “OVERLOADED”, and for all other inputs, the output statement is

“INVALID INPUT”.

Input should be in the form of integer value –

<Integer>

Output must have the following format –

Time Estimated:<Integer> Minutes

Example:

  • Input value

2000

  • Output value

Time Estimated: 25 minutes

Solution

Slot 2 Coding Question 2

To find the question 2 asked in slot 2 with its solution in various programming languages click below –

Slot 2 Question 2

TCS Coding Questions

To find all coding questions asked in TCS NQT 2020 with there solution in multiple languages click below –

TCS Coding Questions

5 comments on “Washing Machine : Fuzzy System”


  • Ajay Hingawe

    import java.util.*;
    class PrepInsta {
    public static void TimeEstimate(int n){
    if (n==0){
    System.out.println(“Time Estimate is: 0 min”);
    }
    else if (n>0 && n2000 && n4000 && n<=7000){
    System.out.println("Time Estimate is : 45min");
    }
    else {
    System.out.println("INVALID INPUT");
    }

    }

    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    TimeEstimate(n);

    }
    }


  • Vaibhav

    import java.util.*;
    public class Machine{
    static void fun(int weight){
    if(weight==0)
    System.out.println(“Time Estimated: 0 minutes”);
    if(weight>0&&weight=2001&&weight4000&&weight7000)
    System.out.println(“OVERLOADED”);
    else
    System.out.println(“INVALID INPUT”);
    }
    public static void main(String []args)
    { Scanner sc=new Scanner(System.in);
    int weight=sc.nextInt();
    fun(weight);

    }
    }


  • 1DS18ME050

    //will this be accepted
    #include
    using namespace std;
    void washingmachine(int w){
    if(w<1){
    cout<=1 && w<=2000){
    cout<=2001 && w<=4000){
    cout<4000 && w<=7000){
    cout<<"Time Estimate:45 Minutes";
    }
    else{
    cout<>w;
    washingmachine(w);
    return 0;

    }


  • Suvendu kumar

    # Code Here
    def Washing_Machine(w):
    if w in range(0, 7001):
    if w == 0:
    print(“Time estimated : 0 minutes”)
    elif w in range(1, 2001):
    print(“Time estimated : 25 minutes”)
    elif w in range(2001, 4001):
    print(“Time estimated : 35 minutes”)
    elif w > 4000:
    print(“Time estimated : 45 minutes”)
    else:
    print(“OVERLOADED”)

    # Driver Code
    weight = int(input())
    Washing_Machine(weight)