import java.util.Scanner;
class TestTelevisionV3
{
public static void main(String [] args)
{
Television tv = new Television (4, 8, true);
tv.printImage();
System.out.println("");
System.out.println("Press P to turn Power On or Off");
System.out.println("Press C to Change the Channel");
System.out.println("Press V to Change the Volume");
System.out.println("Press Q to quit");
System.out.println("");
Scanner myInput = new Scanner(System.in);
String Input1 = myInput.next();
if(Input1 == "P")
{
tv.setPower();
}
if(Input1 == "C")
{
tv.setChannel();
}
if(Input1 == "V")
{
tv.setVolume();
}
if(Input1 == "Q")
{
tv.setPower();
}
else
{
System.out.println("");
System.out.println("Error - Input not recognised!");
System.out.println("");
}
}
}
I am a university students studying software development.
I have been given a task which involves using the code shown so the user inputs P C V or Q the following method is run.
However whenever i run the code my error message appears.
I am aware that the problems has something to do with the scanning method not being able to find string or character inputs..
can someone help me modify the scanner so that inputting P will run the tv.setPower Method