Question

Examine the following class diagram, additional information and answer the questions that follow screenType: char screenSize: int resolution: string price: double standard: boo1 TV(char= L, int= 50, string= HD, double= 600, bool = true ) setorder )void displayvoid getPrice() :double etstandard (:bool; Additional Information Meth tv 〔 char = L,, ユnt S0, string =HD, double -600, bol - true | Constructor with default values. The tional arguments are screenType. screenSize, resolution, price and standard Set the data members accordingly. [Note: Screen type O stands for OLED and L stands for LCD. Screensize is can be HD and UHD getprice double getStandard):bool; setOrdeoi Assessor for data members, price and standard Prompt the user to enter the screenType, screenSize and resolution. The default price $600 is for standard size (50 inch). screen type (LCD) and resolution HD). If there is any change to standard values, set standard to faise. If the screenTvpe is O add S300. If the screenSize is greater than 50 inch, add $20 for LCD TVs and $40 for OLED TVs for each additional inch If the resulution is UHD, add $200 for LCD TVs and $400 for OLED TVs. Update the price accordin Uses cout to display the respective data members. If standard is me, displays Standard TV.· If standard is false. displays Customised TV display:void (a) (b) (c) Write a function, displayMenu that display the following menu. The function accepts Develop C Develop C+ code to implement ALL methods found in the TVclass. validates the input and returns the valid choice to the calling program. code to implement the TV specification. (5 marks) (10 marks) TV Sales Systen Menu 1· Order TV 2. Dasplay Your Order 3. Display the orders that differ fron the standard values (type or size or resolution) 4. Display the TV with the highest price: 5. Exit Enter choice (1 to 5): (5 marks) (d) Write a test driver to test and fiulfil at least the following requirements. ( Declares an array of 5 TV objects. (ii) Calls the function displayMem0 in a loop and invokes the respective methods of (iii) Option1: invoke the method, setOrder and performs boundary check for the (iv) Option 2: uses a loop to invoke the aisplay method of array of IVobjects TV class coresponding to the selected choice. aray of IVobjects Option 3: traverses the array of IVobjects and displays the orders that differ from Option 4: traverses the array of TVobjects to find the IVwith the highest price. loop. (v) the standard values (type or size or resolution) (vi) (vii) Option 5: displays the message. Thank you for using the program... and exit the Include a screen output in vour submission. (15 marks)

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

ANSWER :

#include<iostream>

#include<string>

using namespace std;

//TV class

class TV

{

private :

char screenType;

int screenSize;

string resolution;

double price;

bool standard;

public :

//TV constructor with default values

TV(char screentype = 'L',int screensize = 50,string res= "HD",double pr = 600,bool std = true):

screenType(screentype),screenSize(screensize),resolution(res),price(pr),standard(std)

{

}

//getPrice() method

double getPrice()

{

return price;

}

//getStandard() method

bool getStandard()

{

return standard;

}

//setOrder method()

void setOrder()

{

cout<<"Enter the screenType :";

cin>>screenType;

cout<<"Enter the screenSize :";

cin>>screenSize;

cout<<"Enter the resolution :";

cin>>resolution;

if((screenType != 'L' ||screenType != 'l')||(screenSize !=50 )||(resolution !="HD"))

standard = false;

if(screenType == 'o'||screenType == 'O')

{

price += 300;

}

if(screenSize > 50)

{

if(screenType == 'L' ||screenType == 'l')

{

price += 20;

}

else if(screenType == 'o'||screenType == 'O')

{

price += 40;

}

}

if(resolution == "UHD" && (screenType == 'L' ||screenType == 'l'))

{

price += 200;

}

else if(resolution == "UHD" && (screenType == 'O' ||screenType == 'o'))

{

price += 400;

}

}

//display() method;

void display()

{

if(standard == true)

{

cout<<"Standard TV"<<endl;

}

else

{

cout<<"Customized TV"<<endl;

}

}

};

//displayMenu method

void displayMenu(TV& tv)

{

int choice;

cout<<" TV Sales System Menu"<<endl;

cout<<"------------------------------"<<endl;

cout<<"------------------------------"<<endl;

cout<<"1. Order TV "<<endl;

cout<<"2. Display Your Orders "<<endl;

cout<<"3. Display the orders that differ from the standard values(type or size or resolution): "<<endl;

cout<<"4. Display the TV with highest price: "<<endl;

cout<<"5. Exit "<<endl;

cout<<"Enter choice (1 to 5):"<<endl;

cin>>choice;

switch(choice)

{

case 1:

tv.setOrder();

break;

case 2:

tv.display();

case 3:

case 4:

case 5:

cout<<"Thank you for using the program...."<<endl;

break;

default:

cout<<"Wrong choice";

break;   

}

}

//test driver method test()

void test()

{

TV tv[5];

int i;

for(i=0;i<4;i++)

{

displayMenu(tv[0]);

}

}

//main method

int main()

{

test();

}

OUTPUT :

TV Sales System Menu 1. Order TV 2. Display Your Orders 3. Display the orders that differ from the standard values (type or s

Add a comment
Know the answer?
Add Answer to:
Examine the following class diagram, additional information and answer the questions that follow screenType: char screenSize:...
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
  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

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