Answer to Question #185798 in Programming & Computer Science for amir ali

Question #185798

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-26T12:16:29-0400
#include <iostream>


using namespace std;


class SONY_TV{
private:
	float length;
	float width;
public:
	SONY_TV(){
		length=5;
		width=5;
	}
	SONY_TV(float l,float w){
		length=l;
		width=w;
	}
	float friend calculateArea(SONY_TV s);
	float calculatePrice(){
		return calculateArea(*this)*100;
	}
	void show(){
		cout<<"Sony TV length: "<<length<<"\n";
		cout<<"Sony TV width: "<<width<<"\n";
		cout<<"Sony TV area: "<<calculateArea(*this)<<"\n";
		cout<<"Sony TV price: "<<calculatePrice()<<"\n\n";
	}
};


float calculateArea(SONY_TV s){
	return s.width*s.length;
}


int main(){  
	SONY_TV S1;
	SONY_TV S2(3,2);
	SONY_TV S3(2,5);
	S1.show();
	S2.show();
	S3.show();
	
	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