Boolean to String in Java
<p>How do I make this program stop and go back to turn the tv on and off?</p>

<p>If the OFF is chosen I want it to show the current status of the TV. </p>

<pre><code>import java.util.Scanner;

public class TvTest
{
    public static void main (String[] args)
    {
        String x;
        String y;
        boolean tvStatus = false;
        int chan;
        int volu;

        Scanner input = new Scanner(System.in);
        TV tv2 = new TV(false,2,10);

        // Print out the current status of our TV
        System.out.print(tv2);
        System.out.println();

             System.out.print("Turn TV On or Off ?");
             x = input.nextLine();

             if(x.equalsIgnoreCase("on"))
               {
                   tvStatus = true;

               }else if(x.equalsIgnoreCase("off"))
               {
                   tvStatus =false;
               }

            System.out.print("Change the Channel to : ");
            chan = input.nextInt();

            System.out.print("Increase the volume by 1 or Decrease by -1 : ");
            volu = input.nextInt();

            TV tv1 = new TV(tvStatus,chan,volu);

            if(volu == 1)
            {
                tv1.incrementVolume();

            }else if (volu == -1)
            {
                tv1.decrementVolume();
            }

            System.out.println(tv1);


    }
}// ENd of TvTest
</code></pre>

<p>here is my tv class 
i think there should be way to improve the toString method or even my setter</p>

<pre><code>public class TV
{
    private boolean flag = false;
    private int ch;
    private int vol = 10;

    public TV(boolean onOffSwitch, int channel, int volume)
    {
        this.setFlag(onOffSwitch);
        this.setCh(channel);
        this.setVol(volume);
    }

    public void setFlag(boolean onOffSwitch)
    {
        if(onOffSwitch == true)
        {
            flag = true;
        }else
        {
            flag = false;
        }

    }// End of setFlag

    public boolean getFlag()
    {
        return flag;
    }// End of getFlag

    public void setCh (int newChannel)
    {
        if (newChannel &gt;= 99)
        {
            ch = 99;
        }else
        {
            ch = newChannel;
        }

        if(newChannel &lt; 0)
        {
            ch = 1;
        }
    }//end of setCh

    public int getCh ()
    {
        return ch;
    }// End of getCh

    public void setVol(int newVolume)
    {
        if(newVolume &gt;= 20)
        {
            vol = 20;
        }

    }// End of SetVolume

    public void incrementVolume()
    {
        vol++;
    }

    public void decrementVolume()
    {
        vol--;
    }

    public int getVol()
    {
        return vol;
    }// ENd of getVolume

    public String toString()
    {
        if(flag == false)
        {
            return String.format("%s :%s\n%s:%d\n%s :%d","TV is switched","OFF","TV channel",ch,"TV volume",vol);
        }else
        {
            return String.format("%s :%s\n%s:%d\n%s :%d","TV is switched","ON","TV channel",ch,"TV volume",vol);
        }

    }

}// End of TV class
</code></pre>
