Comp
170 Lab 9
Radio
Define a struct called CRadio or RadioType. Specify attributes to indicate what station it is on, what band is selected (i.e. AM/FM), whether it is on or off, and the volume setting.
The following functions should be written to manipulate a radio.
void TurnOn( CRadio& Radio ); // sets On to true
void TurnOff( CRadio& Radio ); // sets On to false
void IncreaseVolume( CRadio& Radio ); // adds one to the current volume
void DecreaseVolume( CRadio& Radio ); // subtracts one from the current voulume
void SetStation(CRadio& Radio); // within this function you should ask the user for a new station
void SwitchBand( CRadio& Radio ); // if the current band is “AM” it is switch to “FM” and vice-versa
void Display ( const CRadio& Radio ); // neatly displays all of the info for a radio
Place the following restraints on each data member of the CRadio.
Station should be a float between 0-200.
Band should be a character string with 3 characters. It can have the values “AM” or “FM”.
On should be a bool. (true is on, false is off)
Volume should be an int between 0-50.
The following code should help you get started.
#include <iostream>
#include <string>
using namespace std;
struct CRadio
{
float Station;
string Band;
bool On;
int Volume;
CRadio();
};
CRadio::CRadio()
{
Station = 0;
Band = "FM";
On = false;
Volume = 0;
}
void main()
{
CRadio Radio;
//use all of the functions you have written to test your
Radio.
}