11. Battery Monitor Class

 Frame a class Battery with the following:

  • Private data members:
    • voltage (integer, battery voltage in mV)
    • threshold (integer, minimum safe voltage in mV)
       
  • Public methods:
    • Constructor Battery(int voltage, int threshold) → initializes both values
    • bool isLow() const → returns true if voltage < threshold, otherwise false
    • string getStatus() const → returns "LOW" if battery is below threshold, otherwise "OK"
       

The input will contain:

  • voltage threshold

The output should be the battery status: "LOW" or "OK".

 

Example
 Input:

3000 3200

Output:

LOW

Here, voltage = 3000 mV, threshold = 3200 mV.
Since 3000 < 3200, the battery is low.
 

Input:

3700 3200 

Output:

OK

Here, voltage = 3700 mV, threshold = 3200 mV.
 Since 3700 >= 3200, the battery is fine.

Loading...

Input

3000 3200

Expected Output

LOW