Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The final product for this project will demonstrate that you understand how to m

ID: 3863221 • Letter: T

Question

The final product for this project will demonstrate that you understand how to manipulate classes and objects, call methods, create variables and use mathematical operations. Assignment You will create two classes. Radio java and SimRadio java. Radio java should be built according to the class diagram included below. Your radio will be able to store its current station, your favorite station and the volume that it's at now. SimRadio.java will contain the main method In the main method, you should create an instance of your Radio and then utilize its methods m the following way Prompt the user for a station number Prompt the user for a volume. Prompt the user for a favorite station Set the values in the radio based on the information from the user Print out the current information in the Radio (using the accessor methods) Prompt the user for a change in volume. Change the volume by the specified amount (using a mutator method). Print out the current information in the Radio (using the accessor methods) Change the station to the favorite (using a mutator method) Printout the current information in the Radio (using the accessor methods). Example Input/Output: What station do you want to listen to? 99.5 How loud should the radio be? 5 What is your favorite station? 102.7 The current station is: 99.5 The current volume is: 5 The current favorite station is: 102.7

Explanation / Answer

CLASS RADIO:

class Radio{
   private double currentStation;
   private double favoriteStation;
   private int volume;
  
   //Accessors and Mutators for the above instance variables
   public double getCurrentStation() {
       return currentStation;
   }
   public void setCurrentStation(double currentStation) {
       this.currentStation = currentStation;
   }
   public double getFavoriteStation() {
       return favoriteStation;
   }
   public void setFavoriteStation(double favoriteStation) {
       this.favoriteStation = favoriteStation;
   }
   public int getVolume() {
       return volume;
   }
   public void setVolume(int volume) {
       this.volume = volume;
   }
   //End Accessors and Mutators
  
}

CLASS SIMRADIO

import java.io.*;

public class SimRadio {

   public static void main(String[] args)throws IOException {
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       Radio object = new Radio();
       //Taking Input as promted in the question
       System.out.println("What Radio Station you want to hear to?");
       object.setCurrentStation(Double.parseDouble(br.readLine()));//setting values using mutators
      
       System.out.println("How loud should the Radio be?");
       object.setVolume(Integer.parseInt(br.readLine()));//setting values using mutators
      
       System.out.println("What is your favorite Radio Station?");
       object.setFavoriteStation(Double.parseDouble(br.readLine()));//setting values using mutators
      
       //Displaying current information using accesors
       System.out.println(" Your current Radio Station is: "+object.getCurrentStation());
       System.out.println("Your current volume is: "+object.getVolume());
       System.out.println("Your current favorite Radio Station is: "+object.getFavoriteStation() );
      
       ////setting new value to the volume using mutators
       System.out.println(" How much would you like to turn the music up?");
       object.setVolume(object.getVolume() + Integer.parseInt(br.readLine()));
      
       //Displaying current information using accesors
       System.out.println(" Your current Radio Station is: "+object.getCurrentStation());
       System.out.println("Your current volume is: "+object.getVolume());
       System.out.println("Your current favorite Radio Station is: "+object.getFavoriteStation() );
      
       //setting new value to currentStation using mutators
       object.setCurrentStation(object.getFavoriteStation());
      
       //Displaying current information using accesors
       System.out.println(" Your current Radio Station is: "+object.getCurrentStation());
       System.out.println("Your current volume is: "+object.getVolume());
       System.out.println("Your current favorite Radio Station is: "+object.getFavoriteStation() );

   }

}

HOPE THIS HELPS!

FEEL FREE TO COMMENT AND THANKS FOR USING CHEGG

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote