Question

M01 PA C++ Classes and Objects INTRODUCTION: Write a C++ program that implements and utilizes a...

M01 PA

C++ Classes and Objects

INTRODUCTION: Write a C++ program that implements and utilizes a Stereo Receiver Class/Object.

INCLUDE IN YOUR ASSIGNMENT

At the top of each of your C++ programs, you should have at least four lines of documentation:

Program name (the C++ file name(s)), Author (your name), Date last updated, and Purpose (a brief description of what the program accomplishes). Here is an example:

// Program name: tictactoe.cpp

// Author: Rainbow Dash

// Date last updated: 5/26/2016

// Purpose: Play the game of Tic-Tac-Toe

ASSIGNMENT: Programming Exercise

           

Create a StereoReceiver class.

  1. The attributes for the StereoReceiver are:
    1. Manufacturer
    2. Model
    3. Serial Number
    4. Wattage,
    5. Number of Channels
    6. Band (AM/FM)
    7. Frequency (i.e. ‘station’)
    8. Volume (0-10)
    9. Power (i.e. On/Off)
    10. Two other attributes of your own choosing
  2. Create a constructor for the class that receives a Manufacturer, Model, Serial Number, Wattage, and Number of Channels. The constructor should set the attributes provided and also initialize any other attributes (e.g. power, volume, band, frequency, etc.)
  3. Provide separate Accessor/Get Methods that will return Manufacturer, Model, Serial Number, Wattage, Number of Channels, Band, Frequency, Volume, and Power.
  4. Provide separate Mutator/Set Methods that will allow a user to turn the receiver on/off, change the volume, change the band, set the frequency/station, etc.
  5. Provide Accessor/Mutator methods for the attributes you provided as appropriate.

Create a main program that utilizes the StereoReceiver class

  1. Prompt the user for the Manufacturer, Model, Serial Number, Wattage,, and Number of Channels
  2. Validate the information
  3. After Information from the user has been validated, create an object for the StereoReceiver.
  4. Using the Accessor Methods, display the StereoReciever’s information (manufacturer, model, etc.).
  5. Turn on the StereoReceiver using the appropriate method.
  6. Allow the user to change/set the band, frequency, and volume. Validate any input before calling the appropriate functions.
  7. Allow the user to change any of the attributes you created (appropriately)
  8. Display the StereoReceiver’s settings (power, band, station, and volume)
  9. Turn off the StereoReceiver.

            Be sure to include in your program:

  • An appropriate header comment and annotation,
  • Input validation of any values provided by the user.

To submit your assignment:

            In Canvas, go to the Class Module where this assignment is posted, Submit:

            1.The Source code for the lab assignment (*.cpp)

            2.And any Header files for the lab assignment (*.h)

            3. Screen shots illustrating the program ran successfully THREE times (with different values each time).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// StereoReceiver.h

#ifndef INVENTORY_H
#define INVENTORY_H

class StereoReceiver
{
public:
StereoReceiver(string manufacturer, string model,int serial_Number, int wattage, int number_of_Channels) ;
       string getManufacturer();
       void setManufacturer(string manufacturer);
       string getModel();
       void setModel(string model);
       int getSerial_Number();
       void setSerial_Number(int serial_Number);
       int getWattage();
       void setWattage(int wattage);
       int getNumber_of_Channels();
       void setNumber_of_Channels(int number_of_Channels);
       string getBand();
       void setBand(string band);
       int getFrequency();
       void setFrequency(int frequency);
       int getVolume();
       void setVolume(int volume);
       string getPower();
       void setPower(string power);
      
private:
// Declaring variables
string Manufacturer;
string Model;
int Serial_Number;
int Wattage;
int Number_of_Channels;
string Band;
int Frequency;
int Volume;
string Power;
  
};
#endif

________________________

// StereoReceiver.cpp

#include <iostream>
using namespace std;
#include "StereoReceiver.h"

StereoReceiver::StereoReceiver(string manufacturer, string model,
               int serial_Number, int wattage, int number_of_Channels) {
          
           Manufacturer = manufacturer;
           Model = model;
           Serial_Number = serial_Number;
           Wattage = wattage;
           Number_of_Channels = number_of_Channels;
           Band = "FM";
           Frequency = 100;
           Volume = 200;
           Power = "off";
       }
       string StereoReceiver::getManufacturer() {
           return Manufacturer;
       }
       void StereoReceiver::setManufacturer(string manufacturer) {
           Manufacturer = manufacturer;
       }
       string StereoReceiver::getModel() {
           return Model;
       }
       void StereoReceiver::setModel(string model) {
           Model = model;
       }
       int StereoReceiver::getSerial_Number() {
           return Serial_Number;
       }
       void StereoReceiver::setSerial_Number(int serial_Number) {
           Serial_Number = serial_Number;
       }
       int StereoReceiver::getWattage() {
           return Wattage;
       }
       void StereoReceiver::setWattage(int wattage) {
           Wattage = wattage;
       }
       int StereoReceiver::getNumber_of_Channels() {
           return Number_of_Channels;
       }
       void StereoReceiver::setNumber_of_Channels(int number_of_Channels) {
           Number_of_Channels = number_of_Channels;
       }
       string StereoReceiver::getBand() {
           return Band;
       }
       void StereoReceiver::setBand(string band) {
           Band = band;
       }
       int StereoReceiver::getFrequency() {
           return Frequency;
       }
       void StereoReceiver::setFrequency(int frequency) {
           Frequency = frequency;
       }
       int StereoReceiver::getVolume() {
           return Volume;
       }
       void StereoReceiver::setVolume(int volume) {
           Volume = volume;
       }
       string StereoReceiver::getPower() {
           return Power;
       }
       void StereoReceiver::setPower(string power) {
           Power = power;
       }

_______________________

// main.cpp

#include <iostream>
using namespace std;
#include "StereoReceiver.h"

int main()
{
string Manufacturer;
string Model;
int Serial_Number;
int Wattage;
int Number_of_Channels;
string Band;
int Frequency;
int Volume;
string Power;
  
cout<<"Enter Manufacturer :";
getline(cin,Manufacturer);
cout<<"Enter Model :";
cin>>Model;
cout<<"Enter Serial Number :";
cin>>Serial_Number;
cout<<"Enter Wattage :";
cin>>Wattage;
cout<<"Enter No of Channels :";
cin>>Number_of_Channels;
cout<<"Enter Band :";
cin>>Band;
cout<<"Enter Frequency :";
cin>>Frequency;
cout<<"Enter Volume :";
cin>>Volume;
cout<<"Set Power (ON/OFF):";
cin>>Power;
  
StereoReceiver sr(Manufacturer,Model,Serial_Number,Wattage,Number_of_Channels);
sr.setBand(Band);
sr.setFrequency(Frequency);
sr.setVolume(Volume);
sr.setPower(Power);
  
cout<<"______Displaying Info_____"<<endl;
cout<<"Manufacturer :"<<sr.getManufacturer()<<endl;
cout<<"Model :"<<sr.getModel()<<endl;
cout<<"Serial Number :"<<sr.getSerial_Number()<<endl;
cout<<"Wattage :"<<sr.getWattage()<<endl;
cout<<"No of Channels :"<<sr.getNumber_of_Channels()<<endl;
cout<<"Band :"<<sr.getBand()<<endl;
cout<<"Frequency :"<<sr.getFrequency()<<endl;
cout<<"Volume :"<<sr.getVolume()<<endl;
cout<<"Power :"<<sr.getPower()<<endl;
  
  
  
return 0;
}

___________________________

Output;

__________________Thank You

Add a comment
Know the answer?
Add Answer to:
M01 PA C++ Classes and Objects INTRODUCTION: Write a C++ program that implements and utilizes a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • In C++, Step 1: Implement the Student Class and write a simple main() driver program to...

    In C++, Step 1: Implement the Student Class and write a simple main() driver program to instantiate several objects of this class, populate each object, and display the information for each object. The defintion of the student class should be written in an individual header (i.e. student.h) file and the implementation of the methods of the student class should be written in a corresponding source (i.e. student.cpp) file. Student class - The name of the class should be Student. -...

  • Please include comments in java Create a command line program that can be used for computer...

    Please include comments in java Create a command line program that can be used for computer inventory purposes Create a super class that will store the following data: CPU speed Amount of RAM Hard Disk size Operating System Allow the user to enter data using any units of measurement they desire (i.e. - 500GB or 1TB for hard disk size). Create a class that inherits from the previous class and stores information for a Windows based computer. Store the following...

  • using java write a code with notepad++ Create the following classes using inheritance and polymorphism Ship...

    using java write a code with notepad++ Create the following classes using inheritance and polymorphism Ship (all attributes private) String attribute for the name of ship float attribute for the maximum speed the of ship int attribute for the year the ship was built Add the following behaviors constructor(default and parameterized) , finalizer, and appropriate accessor and mutator methods Override the toString() method to output in the following format if the attributes were name="Sailboat Sally", speed=35.0f and year built of...

  • In python Create a class that holds personal data: name, address, age, and phone number. Write...

    In python Create a class that holds personal data: name, address, age, and phone number. Write the necessary get (accessor) and set mutator methods. Also include a program that creates three instances of the class. This could be you and 2 friends or 2 family members.

  • Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and...

    Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and a driver program called invoiceDriver.cpp. The class Invoice is used in a hardware store to represent an invoice for an item sold at the store. An invoice class should include the following: A part number of type string A part description of type string A quantity of the item being purchased of type int A price per item of type int A class constructor...

  • Write a Python program that creates a class which represents a candidate in an election. The...

    Write a Python program that creates a class which represents a candidate in an election. The class must have the candidates first and last name, as well as the number of votes received as attributes. The class must also have a method that allows the user to set and get these attributes. Create a separate test module where instances of the class are created, and the methods are tested. Create instances of the class to represent 5 candidates in the...

  • IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand...

    IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand the Application The assignment is to first create a class calledTripleString.TripleStringwill consist of threeinstance attribute strings as its basic data. It will also contain a few instance methods to support that data. Once defined, we will use it to instantiate TripleString objects that can be used in our main program. TripleString will contain three member strings as its main data: string1, string2, and string3....

  • *Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented...

    *Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented programming using classes to create objects. PROBLEM DEFINITION: Write a class named Employee that holds the following data about an employee in attributes: name, IDnumber, department, jobTitle The class should have 8 methods as follows:  For each attribute, there should be a method that takes a parameter to be assigned to the attribute. This is known as a mutator method.  For each...

  • Use Dev-C++ to create a program using the program requirements listed below. Write a program that...

    Use Dev-C++ to create a program using the program requirements listed below. Write a program that displays the income tax due in the state of Euphoria on a taxable income (in whole dollars) entered by the user, according to the tax table shown in Table 11.1. Table 11.1 Tax table Taxable Income From -To Tax Due $0 - $49,999 $0 + 5% of amount over $0 $50,000 - $99,999 $2,500 + 7% of amount over $50,000 $100,000... $6,000 + 9%...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT