Answer to Question #185728 in Programming & Computer Science for Shahnawaz

Question #185728

Q.No.4 Sony TV Manufacturer want you to design a program that will help their customers to

check the price along with the dimensions for their products to be purchased. For this

Carefully read all the instructions and follow the requirements.

o Create a class called SONY_TV along with two constructors as follows:

o A Default constructor to set the length of TV.

o A parameterized constructor that will receive the width in float.

o By using a friend function calculate the area of the SonyTV

o Create a member function to calculate the price of the sony TV by multiplying the area

with Rs 100.

o Create a show( ) function to show the details of the purchased sony TV.

In the main you will construct three objects that will show the use of the two constructors. After

calling the constructor it will call the area function, and then the price calculation function.

( Marks 6)


1
Expert's answer
2021-04-26T11:45:52-0400
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//Create a class called SONY_TV along with two constructors as follows:
class SONY_TV{
private:
	float lengthOfTV;
	float widthOfTV;
public:
	//A Default constructor to set the length of TV.
	SONY_TV(){
		this->lengthOfTV=5;
		this->widthOfTV=5;
	}
	//A parameterized constructor that will receive the width in float.
	SONY_TV(float length,float width){
		this->lengthOfTV=length;
		this->widthOfTV=width;
	}


	//By using a friend function calculate the area of the SonyTV
	float friend calculateAreaSonyTV(SONY_TV SONYTV);
	//Create a member function to calculate the price of the sony TV by multiplying the area with Rs 100.
	float calculatePriceSonyTV(){
		return calculateAreaSonyTV(*this)*100;
	}
	// Create a show( ) function to show the details of the purchased sony TV.
	void show(){
		cout<<"The length of Sony TV: "<<this->lengthOfTV<<"\n";
		cout<<"The width of Sony TV: "<<this->widthOfTV<<"\n";
		cout<<"The area of the Sony TV: "<<calculateAreaSonyTV(*this)<<"\n";
		cout<<"The price of the Sony TV: "<<calculatePriceSonyTV()<<"\n\n";
	}
};


//By using a friend function calculate the area of the SonyTV
float calculateAreaSonyTV(SONY_TV SONYTV){
	return SONYTV.widthOfTV*SONYTV.lengthOfTV;
}


int main(){  
	//In the main you will construct three objects that will show the use of the two constructors. After
	//calling the constructor it will call the area function, and then the price calculation function.
	SONY_TV SONYTV1;
	SONY_TV SONYTV2(4,4);
	SONY_TV SONYTV3(5,4);
	SONYTV1.show();
	SONYTV2.show();
	SONYTV3.show();


	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS