Java TV Controller Everyone is familiar with a television Yo

Java TV Controller Everyone is familiar with a television. You are going to create a program that mimics the controlling of the operation of a television remote control. Think about a television in general. It has some basic controls. There is a control to turn the power on and off, change the channel, and for the volume. At any point in time, the television’s state can be described by how these controls are set. You will have to create the following attributes: powerOn // holds the value true if the power is on, and false if the power is off. channel // holds the value of the station that the television is showing. The range of this value is 2 through 99. Set its initial value to 3 volume // holds a number value representing the loudness (0 being no sound). The range of this value is 0 to 10. Set its initial value to 5 mode // sets the input mode of the TV. Set its initial value to TV Input: Accept the full command (i.e., Turn On). Be able to handle case insensitive input and space characters. Output: For all of your output messages other than the Banner message, use the DisplayMessage method only!! Upon starting your program, you will display the Banner message (invoke the Banner method). When you Exit the program, you will display the message “Thank you for using the Java Remote Controller” For the main body of your program, you will then ask the user for input and loop continuously looking for further user input until Exit is entered. Upon entering one of the following options, you will call the respective method to perform the operations. The User Inputs are: Turn On – turns on the TV Turn Off – turns off the TV Volume Up – turns up the volume by 1 Volume Down – turns down the volume by 1. Channel Up – increments the channel by 1. Channel Down – decrements the channel by 1. Mode TV – sets the mode selection to TV Mode DVD – sets the mode selection to DVD Exit – turns off the remote control and exits the program. You will have to write methods named: TurnOn: Accepts the powerOn parameter to allow for determining if the powerOn parameter is true or false Return value is updated powerOn attribute If the powerOn value is already true Display a message “TV already on” If the powerOn value is false Sets the powerOn attribute value to true. Display a message “TV On, Your Channel is xxx and the Volume is xxx” TurnOff: Accepts the powerOn parameter to allow for determining if the powerOn parameter is true or false Return value is updated powerOn attribute Sets the powerOn attribute value to false Display a message “TV is now off” If the powerOn value is already false, DIsplay a message “TV already off” VolumeUp: Accepts the powerOn parameter to allow for determining if the powerOn parameter is true or false and the volume parameter Return value is updated volume attribute If the powerOn parameter is false Display a message “TV is off” Test the value of the volume attribute - You cannot increment the volume attribute greater than 10. If the volume value is less than 10, increment the volume value by 1. If the volume attribute is 10, display “Maximum Volume” VolumeDown: Accepts the powerOn parameter to allow for determining if the powerOn parameter is true or false and the volume parameter Return value is updated volume attribute If the powerOn parameter is false Display a message “TV is off” If the powerOn parameter is true, test the value of the volume attribute - You cannot decrement the volume attribute lower than 0. If the value is greater than 0, decrement the volume attribute value by 1 If the value is 0, display “Sound Muted” ChannelUp Accepts the powerOn parameter to allow for determining if the powerOn parameter is true or false and the channel parameter Return value is the updated channel parameter If the powerOn parameter is false Display a message “TV is off” If the powerOn parameter is true, test the value of the channel attribute – the channel range is from 2 through 99. If the channel value is less than 99, increment that channel value by 1 If the channel value is 99, set the channel value to 2 Display the current channel using the display method “Channel x” ChannelDown Accepts the powerOn parameter to allow for determining if the powerOn parameter is true or false and the channel parameter Return value is the updated channel parameter If the powerOn parameter is false Display a message “TV is off” If the powerOn parameter is true, test the value of the channel attribute – the channel range is from 2 through 99. If the channel value is less than 99, increment that channel value by 1 If the channel value is 99, set the channel value to 2 Display the current channel using the display method “Channel x” SetModeTV: Accepts the powerOn parameter to allow for determining if the powerOn parameter is true or false Return is the updated mode value If the powerOn parameter is false Display a message “TV is off” If the powerOn parameter is true display “TV Mode” Return mode set to TV SetModeDVD: Accepts the powerOn parameter to allow for determining if the powerOn parameter is true or false Return is the updated mode value If the powerOn parameter is false Display a message “TV is off” If the powerOn parameter is true display “DVD Mode” Return mode set to DVD // methods that I’m providing /* Common Display methods */ public static void DisplayMessage(String msg) { System.out.println(msg); } // end method /* Display banner */ public static void Banner() { System.out.println(\"Welcome to your Java TV Remote Control\"); System.out.println(\"Please enter your selection\"); System.out.println(\"Turn On - turns on your TV\"); System.out.println(\"Turn Off - turns off your TV\"); System.out.println(\"Volume Up - turns up the volume\"); System.out.println(\"Volume Down - turn down the volume\"); System.out.println(\"Channel Up - increments the channel\"); System.out.println(\"Channel Down - decrements the channel\"); System.out.println(\"Mode TV – set TV mode\"); System.out.println(\"Mode DVD – set DVD mode\"); System.out.println(); System.out.println(\"Please enter your selection\"); } // end method

Solution

import java.util.Scanner;

public class JavaRemoteController {
   static boolean powerOn;
   static int channel = 3;
   static int volume = 5;
   static String mode = \"TV\";
   static final int MIN_CHANNEL = 2;
   static final int MAX_CHANNEL = 99;
   static final int MIN_VOLUME = 0;
   static final int MAX_VOLUME = 10;
  
   // turn on method
   public static boolean TurnOn(boolean powerOn) {
       if (powerOn) {
           DisplayMessage(\"TV already on\");
           return powerOn;
       } else {
           DisplayMessage(\"TV On, Your Channel is \" + channel + \" and the Volume is \" + volume + \"\");
       }
       return !powerOn;
   }

   // turn off method
   public static boolean TurnOff(boolean powerOn) {
       if (!powerOn) {
           DisplayMessage(\"TV already off\");
           return powerOn;
       } else {
           DisplayMessage(\"TV is now off\");
       }
       return !powerOn;
   }

  
   // volume up method
   public static int VolumeUp(boolean powerOn) {
       if (!powerOn) { // if power is off we will show that tv is off
           DisplayMessage(\"TV is off\");
           return volume;
       }
       if (volume == MAX_VOLUME) { // if volume is at maximum level we need to show it is maximum
           DisplayMessage(\"Maximum Volume\");
           return volume;
       }
       volume++; // increase the volume
       DisplayMessage(\"Volume is \"+volume);
       return volume;

   }

  
   // voulme down method
   public static int VolumeDown(boolean powerOn) {
       if (!powerOn) { // if power is off we will show that tv is off
           DisplayMessage(\"TV is off\");
           return volume;
       }
       if (volume == MIN_VOLUME) { // if volume is at minimum level we need to show it is muted
           DisplayMessage(\"Sound Muted\");
           return volume;
       }
      
       volume--; // decrease the volume
       DisplayMessage(\"Volume is \"+volume);
       return volume;

   }

   public static int ChannelUp(boolean powerOn) {
       if (!powerOn) { // if power is off we will show that tv is off
           DisplayMessage(\"TV is off\");
           return channel;
       }
       if (channel == MAX_CHANNEL) { // if channel is at maximum level we switch to minimum
           DisplayMessage(\"Channel \" + MIN_CHANNEL);
           channel = MIN_CHANNEL;
           return channel;
       }
      
       channel++; // increase the channel
       DisplayMessage(\"Channel is \"+channel);
      
       return channel;

   }

   public static int ChannelDown(boolean powerOn) {
       if (!powerOn) { // if power is off we will show that tv is off
           DisplayMessage(\"TV is off\");
           return channel;
       }
       if (channel == MIN_CHANNEL) { // if channel is at minimum level we switch to maximum
           DisplayMessage(\"Channel \" + MAX_CHANNEL);
           channel = MAX_CHANNEL;
           return channel;
       }

       channel--; // decrease the channel
       DisplayMessage(\"Channel is \"+channel);
      
       return channel;

   }

   public static String SetModeTV(boolean powerOn) {
       if (!powerOn) { // if power is off we will show that tv is off
           DisplayMessage(\"TV is off\");
           return mode;
       }
       mode = \"TV\"; //change the mode to tv
       return mode;

   }

   public static String SetModeDVD(boolean powerOn) {
       if (!powerOn) { // if power is off we will show that tv is off
           DisplayMessage(\"TV is off\");
           return mode;
       }
       mode = \"DVD\";// change the mode to dvd
       return mode;

   }

   /* Common Display methods */
   public static void DisplayMessage(String msg) {
       System.out.println(msg);
   } // end method /* Display banner */

   public static void Banner() {
       System.out.println(\"---------------------------------------------\");
       System.out.println(\"Welcome to your Java TV Remote Control\");
       System.out.println(\"Please enter your selection\");
       System.out.println(\"Turn On - turns on your TV\");
       System.out.println(\"Turn Off - turns off your TV\");
       System.out.println(\"Volume Up - turns up the volume\");
       System.out.println(\"Volume Down - turn down the volume\");
       System.out.println(\"Channel Up - increments the channel\");
       System.out.println(\"Channel Down - decrements the channel\");
       System.out.println(\"Mode TV – set TV mode\");
       System.out.println(\"Mode DVD – set DVD mode\");
       System.out.println(\"Exit\");
       System.out.println(\"Please enter your selection\");
       System.out.println(\"---------------------------------------------\");

   } // end method

   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       String choice = \"\";
       do {
           Banner();
           choice = sc.nextLine(); // take the input from the user
           if (choice.equalsIgnoreCase(\"Turn On\") || choice.equalsIgnoreCase(\"TurnOn\")) {
               powerOn=TurnOn(powerOn);
           } else if (choice.equalsIgnoreCase(\"Turn Off\") || choice.equalsIgnoreCase(\"TurnOff\")) {
               powerOn=TurnOff(powerOn);
           } else if (choice.equalsIgnoreCase(\"Volume Up\") || choice.equalsIgnoreCase(\"VolumeUp\")) {
               VolumeUp(powerOn);
           } else if (choice.equalsIgnoreCase(\"Volume Down\") || choice.equalsIgnoreCase(\"VolumeDown\")) {
               VolumeDown(powerOn);
           } else if (choice.equalsIgnoreCase(\"Channel Up\") || choice.equalsIgnoreCase(\"ChannelUp\")) {
               ChannelUp(powerOn);
           } else if (choice.equalsIgnoreCase(\"Channel Down\") || choice.equalsIgnoreCase(\"ChannelDown\")) {
               ChannelDown(powerOn);
           } else if (choice.equalsIgnoreCase(\"Mode TV\") || choice.equalsIgnoreCase(\"ModeTV\")) {
               SetModeTV(powerOn);
           } else if (choice.equalsIgnoreCase(\"Mode DVD\") || choice.equalsIgnoreCase(\"ModeDVD\")) {
               SetModeDVD(powerOn);
           }else if(choice.equalsIgnoreCase(\"exit\")){
               powerOn=false;
               DisplayMessage(\"Exited the remote control program\");
           }else{
               DisplayMessage(\"wrong selection\");
           }
       } while (!choice.equalsIgnoreCase(\"exit\")); // loop breaks when user enter exit
   }

}

-------------------------------------------------------------output-----------------------------------------------------------------------------------

---------------------------------------------
Welcome to your Java TV Remote Control
Please enter your selection
Turn On - turns on your TV
Turn Off - turns off your TV
Volume Up - turns up the volume
Volume Down - turn down the volume
Channel Up - increments the channel
Channel Down - decrements the channel
Mode TV – set TV mode
Mode DVD – set DVD mode
Exit
Please enter your selection
---------------------------------------------
turn on
TV On, Your Channel is 3 and the Volume is 5
---------------------------------------------
Welcome to your Java TV Remote Control
Please enter your selection
Turn On - turns on your TV
Turn Off - turns off your TV
Volume Up - turns up the volume
Volume Down - turn down the volume
Channel Up - increments the channel
Channel Down - decrements the channel
Mode TV – set TV mode
Mode DVD – set DVD mode
Exit
Please enter your selection
---------------------------------------------
volumedown
Volume is 4
---------------------------------------------
Welcome to your Java TV Remote Control
Please enter your selection
Turn On - turns on your TV
Turn Off - turns off your TV
Volume Up - turns up the volume
Volume Down - turn down the volume
Channel Up - increments the channel
Channel Down - decrements the channel
Mode TV – set TV mode
Mode DVD – set DVD mode
Exit
Please enter your selection
---------------------------------------------
channeldown
Channel is 2
---------------------------------------------
Welcome to your Java TV Remote Control
Please enter your selection
Turn On - turns on your TV
Turn Off - turns off your TV
Volume Up - turns up the volume
Volume Down - turn down the volume
Channel Up - increments the channel
Channel Down - decrements the channel
Mode TV – set TV mode
Mode DVD – set DVD mode
Exit
Please enter your selection
---------------------------------------------
channel down
Channel 99
---------------------------------------------
Welcome to your Java TV Remote Control
Please enter your selection
Turn On - turns on your TV
Turn Off - turns off your TV
Volume Up - turns up the volume
Volume Down - turn down the volume
Channel Up - increments the channel
Channel Down - decrements the channel
Mode TV – set TV mode
Mode DVD – set DVD mode
Exit
Please enter your selection
---------------------------------------------
modetv
---------------------------------------------
Welcome to your Java TV Remote Control
Please enter your selection
Turn On - turns on your TV
Turn Off - turns off your TV
Volume Up - turns up the volume
Volume Down - turn down the volume
Channel Up - increments the channel
Channel Down - decrements the channel
Mode TV – set TV mode
Mode DVD – set DVD mode
Exit
Please enter your selection
---------------------------------------------

Welcome to your Java TV Remote Control
Please enter your selection
Turn On - turns on your TV
Turn Off - turns off your TV
Volume Up - turns up the volume
Volume Down - turn down the volume
Channel Up - increments the channel
Channel Down - decrements the channel
Mode TV – set TV mode
Mode DVD – set DVD mode
Exit
Please enter your selection
---------------------------------------------
exit
Exited the remote control program

Java TV Controller Everyone is familiar with a television. You are going to create a program that mimics the controlling of the operation of a television remote
Java TV Controller Everyone is familiar with a television. You are going to create a program that mimics the controlling of the operation of a television remote
Java TV Controller Everyone is familiar with a television. You are going to create a program that mimics the controlling of the operation of a television remote
Java TV Controller Everyone is familiar with a television. You are going to create a program that mimics the controlling of the operation of a television remote
Java TV Controller Everyone is familiar with a television. You are going to create a program that mimics the controlling of the operation of a television remote
Java TV Controller Everyone is familiar with a television. You are going to create a program that mimics the controlling of the operation of a television remote

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site