Could u tell me why the following problem is coming on running the program where im getting the out twice each time wen i shd get it only once , wen im entering a input im getting the menu twice
import java.io.*;
class Television{
private String MANUFACTURER;
private int SCREEN_SIZE;
private boolean powerON;
private int volume = 0;
private int channel = 0;
public Television(String brand, int size){
MANUFACTURER = brand;
SCREEN_SIZE = size;
}
public void setChannel(char station){
if(station == 'g') channel++;
if(station == 'h') channel--;
}
public void power(){
if( powerON == false) powerON = true;
else powerON = false;
}
public void increaseVolume(){
volume++;
}
public void decreaseVolume(){
volume--;
}
public int getChannel(){
if(channel == 100){channel = 0;}
if(channel < 0 ){channel = 99;}
return channel;
}
public int getVolume(){
if(volume < 0) volume = 0;
return volume;
}
public String getManufacturer(){
return MANUFACTURER;
}
public int getScreenSize(){
return SCREEN_SIZE;
}
public static void main(String args[] )throws Exception{
BufferedReader br = new BufferedReader(newInputStreamReader(System.in));
boolean q1 = true;
Television t1 = new Television("Sony Television",32);
Television t2 = new Television("ONIDA Television",29);
while(q1){
System.out.print("You have a " + t1.getScreenSize() +"
inch " + t1.getManufacturer() + " in");
if(t1.powerON == false) System.out.println(" off mode");
else System.out.println(" on mode");
System.out.println("1: Press p to toggle power state.");
System.out.println("2: Press g and h to increase or decrease
channel.");
System.out.println("3: Press f and j to increase or decrease
volume.");
System.out.println("4: Press q to stop performing
operations.");
System.out.println("Volume: " + t1.getVolume());
System.out.println("Channel: " + t1.getChannel());
char a = (char)br.read();
if(a == 'p'){
System.out.println("1");
t1.power();
System.out.println("2");
}
if(a == 'g') t1.setChannel(a);
if(a == 'h') t1.setChannel(a);
if(a == 'f') t1.increaseVolume();
if(a == 'j') t1.decreaseVolume();
if(a == 'q') q1 = false;
}
}
}