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

Examine the following class diagram, additional information and answer the quest

ID: 3594166 • Letter: E

Question

Examine the following class diagram, additional information and answer the questions that follow: TV screenType: char screenSize: int resolution: string price: double standard: bool TV(char= 'L', int = 50, string ="HD", double = true) setOrder () :void display) :voicd getPrice() :double 600, bool etstandard() :bool; dditional Information: Method Remarks TV (char -L', int - 50, string -"HD", Constructor with default values. The double = 600, bool = true) positional 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 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 false. If the screenType is 'O' add $300. 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 accordingl Uses cout to display the respective data members. If standard is true, displays "Standard TV". If standard is false. displays "Customised TV" getPrice ) :double getstandard ) :bool setorder ) :void display ) :voicd

Explanation / Answer

#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
//Class TV definition
class TV
{
//Data member to store data
char screenType;
int screenSize;
string resolution;
double price;
bool standard;
public:
//Prototype of member function
//Parameterized constructor with default values
TV(char = 'L', int = 50, string = "HD", double = 600, bool = true);
void setOrder();
void display();
double getPrice();
bool getStandard();
void displayDiffer();
void displayHighestPrice(TV[], int);
};//End of class

//Method to return price
double TV::getPrice()
{
return price;
}//End of method

//Method to return standard
bool TV::getStandard()
{
return standard;
}//End of method

//Parameterized constructor with default values
TV::TV(char l, int ss, string re, double pr, bool s)
{
screenType = l;
screenSize = ss;
resolution = re;
price = pr;
standard = s;
}//End of constructor

//Method to accept data
void TV::setOrder()
{
//Accepts data from the user
cout<<" Enter Screen Type: ";
cin>>screenType;
cout<<" Enter Screen Size: ";
cin>>screenSize;
cout<<" Enter Screen Resolution: ";
cin>>resolution;
//Checks if the entered data is differ from the default data
if(screenSize != 50 || screenType != 'L' || resolution != "HD")
//Set the standard to false
standard = false;
//Checks if the screen type is 'O'
if(screenType == 'O')
//Add 300 to price
price += 300;
//Checks if screen size is greater than 50
if(screenSize > 50)
{
//Checks if the screen type is 'L'
if(screenType == 'L')
{
//Calculate the size difference
int diff = screenSize - 50;
//Adds 20 for each difference
price = price + (diff * 20);
}//End of inner if
//Checks if the screen type is 'O'
if(screenType == 'O')
{
//Calculate the size difference
int diff = screenSize - 50;
//Adds 40 for each difference
price = price + (diff * 40);
}//End inner if
}//End of outer if
//Checks if the resolution is "UHD"
if(resolution == "UHD")
{
//Checks if the screen type is 'L'
if(screenType == 'L')
//Adds 200 to the price
price += 200;
//Checks if the screen type is 'O'
else if(screenType == 'O')
//Adds 200 to the price
price += 400;
}//End of if
}//End of method

//Method to display all TV information
void TV::display()
{
//Displays TV information
cout<<" Screen Type: "<<screenType;
cout<<" Screen Size: "<<screenSize;
cout<<" Screen Resolution: "<<resolution;
cout<<" Price: "<<price;
//Checks if the standard value is true
if(standard)
cout<<" Standard TV";
//Otherwise
else
cout<<" Customized TV";
}//End of method

//Method to display the TV information which is differ from the standard TV set
void TV::displayDiffer()
{
//Checks the difference of standard TV set
if(screenType != 'L' || screenSize != 50 || resolution != "HD")
{
//Displays TV information
cout<<" Screen Type: "<<screenType;
cout<<" Screen Size: "<<screenSize;
cout<<" Screen Resolution: "<<resolution;
cout<<" Price: "<<price;
//Checks if the standard value is true
if(standard)
cout<<" Standard TV";
//Otherwise
else
cout<<" Customized TV";
}//End of if
}//End of method

//Method to display the TV information with highest price
void TV::displayHighestPrice(TV tt[], int n)
{
//Initially highest price is the first TV price
int high = tt[0].price;
//To store the location of the highest price TV object
int loc;
//Loops till end of record
for(int x = 1; x < n; x++)
{
//Checks if the current TV price is greater than earlier TV price
if(tt[x].price > high)
{
//Set the current TV price as the highest TV price
high = tt[x].price;
//Stores the location of the counter
loc = x;
}//End of if
}//End of for
//Displays the TV information
cout<<" Screen Type: "<<tt[loc].screenType;
cout<<" Screen Size: "<<tt[loc].screenSize;
cout<<" Screen Resolution: "<<tt[loc].resolution;
cout<<" Price: "<<tt[loc].price;
//Checks if the standard value is true
if(tt[loc].standard)
cout<<" Standard TV";
//Otherwise
else
cout<<" Customized TV";
}//End of method

//Method to display menu and accept user choice
int menu()
{
int choice;
//Displays menu
cout<<" 1. Order TV";
cout<<" 2. Display Your Order";
cout<<" 3. Display the orders that differ from the standard values (type or size or resolution)";
cout<<" 4. Display the TV with highest price";
cout<<" 5. Exit";
//Accepts user choice
cout<<" Enter choice (1 to 5): ";
cin>>choice;
//Returns user choice
return choice;
}//End of method

//Main method definition
int main()
{
//Creates an array of 5 objects
TV t[5];
//Sets the size to 5
int c = 5;
//To store user choice
int choice;
//Loops till user choice is not 5
do
{
//Displays menu and store the choice value returned by the method
choice = menu();
//Checks the choice value and calls the appropriate method
switch(choice)
{
case 1:
for(int x = 0; x < c; x++)
t[x].setOrder();
break;
case 2:
for(int x = 0; x < c; x++)
t[x].display();
break;
case 3:
for(int x = 0; x < c; x++)
t[x].displayDiffer();
break;
case 4:
t[0].displayHighestPrice(t, c);
break;
case 5:

cout<<" Thank you for using the program.....";
exit(0);
}//End of switch - case
}while(1);//End of do - while
}//End of main method

Sample Run:

1. Order TV
2. Display Your Order
3. Display the orders that differ from the standard values (type or size or resolution)
4. Display the TV with highest price
5. Exit
Enter choice (1 to 5): 1

Enter Screen Type: L

Enter Screen Size: 50

Enter Screen Resolution: HD

Enter Screen Type: O

Enter Screen Size: 55

Enter Screen Resolution: UHD

Enter Screen Type: O

Enter Screen Size: 65

Enter Screen Resolution: HD

Enter Screen Type: L

Enter Screen Size: 44

Enter Screen Resolution: HD

Enter Screen Type: O

Enter Screen Size: 57

Enter Screen Resolution: UHD

1. Order TV
2. Display Your Order
3. Display the orders that differ from the standard values (type or size or resolution)
4. Display the TV with highest price
5. Exit
Enter choice (1 to 5): 2

Screen Type: L
Screen Size: 50
Screen Resolution: HD
Price: 600
Standard TV
Screen Type: O
Screen Size: 55
Screen Resolution: UHD
Price: 1500
Customized TV
Screen Type: O
Screen Size: 65
Screen Resolution: HD
Price: 1500
Customized TV
Screen Type: L
Screen Size: 44
Screen Resolution: HD
Price: 600
Customized TV
Screen Type: O
Screen Size: 57
Screen Resolution: UHD
Price: 1580
Customized TV
1. Order TV
2. Display Your Order
3. Display the orders that differ from the standard values (type or size or resolution)
4. Display the TV with highest price
5. Exit
Enter choice (1 to 5): 3

Screen Type: O
Screen Size: 55
Screen Resolution: UHD
Price: 1500
Customized TV
Screen Type: O
Screen Size: 65
Screen Resolution: HD
Price: 1500
Customized TV
Screen Type: L
Screen Size: 44
Screen Resolution: HD
Price: 600
Customized TV
Screen Type: O
Screen Size: 57
Screen Resolution: UHD
Price: 1580
Customized TV
1. Order TV
2. Display Your Order
3. Display the orders that differ from the standard values (type or size or resolution)
4. Display the TV with highest price
5. Exit
Enter choice (1 to 5): 4

Screen Type: O
Screen Size: 57
Screen Resolution: UHD
Price: 1580
Customized TV
1. Order TV
2. Display Your Order
3. Display the orders that differ from the standard values (type or size or resolution)
4. Display the TV with highest price
5. Exit
Enter choice (1 to 5):5

Thank you for using the program.....

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