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

C++ program- The screen size of a TV is given by the length of the rectangular d

ID: 3714826 • Letter: C

Question

C++ program- The screen size of a TV is given by the length of the rectangular diagonal. Traditional TVs come in 4:3 ratio, that is, the ratio of length to width is 4 to 3. This means, if the length is x inches, then the width is (3/4)x. LCD TVs come in 16:9 ratio. Write a program that: 1. Prompts the user to input the length of the diagonal (in inches) of the screen 2. Allows the user to select which type of TV the user would like to view the dimensions for Ex. 1. Traditional TV area. 2. LCD TV Area 3. Both types of TVs area Have the program calculate and display the: 1. Screen length 2. Screen width 3. Screen area for the specified type of TV.

Explanation / Answer

Solution:

code:

#include<bits/stdc++.h>

using namespace std;

int main()

{ float d;//diagonal

float l,b,area;

cout<<"Enter the diagonal length(inches): ";

cin>>d;//take diagonal length as input

int c;

cout<<"Select from following: 1. Standard TV(4:3) 2. Wide ScreenTV(16:9) 3. Both types ";

cin>>c;

//standard

if(c==1)

{ float x=d/5; //d^2=(4*x)^2+(3*x)^2

l=4*x; //length

b=3*x; //breadth

area=l*b; //area

cout<<"Standard TV: length is "<<l<<"inches, breadth is "<<b<<"inches, area is "<<area<<endl;

}else if(c==2) //widescreen

{ float x=sqrt(d*d/(16*16+9*9)); //d^2=(16*x)^2+(9*x)^2

l=4*x; //length

b=3*x; //breadth

area=l*b; //area

cout<<"widescreen TV: length is "<<l<<"inches, breadth is "<<b<<"inches, area is "<<area<<endl;

}else //both

{ float x=d/5; //d^2=(4*x)^2+(3*x)^2

l=4*x; //length

b=3*x; //breadth

area=l*b; //area

cout<<"Standard TV: length is "<<l<<"inches, breadth is "<<b<<"inches, area is "<<area<<endl;

x=sqrt(d*d/(16*16+9*9)); //d^2=(16*x)^2+(9*x)^2

l=4*x; //length

b=3*x; //breadth

area=l*b; //area

cout<<"widescreen TV: length is "<<l<<"inches, breadth is "<<b<<"inches, area is "<<area<<endl;

}

return 0;

}

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

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