Answer to Question #253865 in C++ for papinash

Question #253865

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 prompts the user to input the length of the diagonal (in inches) of the screen and allows the user to select which type of TV’s screen length, screen width and screen area the user would like to calculate. Have the program display the desired results. 


1
Expert's answer
2021-10-20T07:39:17-0400

Source code

#include <iostream>


using namespace std;


int main()
{
    cout<<"Enter the length of the Tv in inches: ";
    double length;
    cin>>length;
    
    cout<<"Choose the type of TV\n1. Traditional TV (4:3)\n2. LCD TV (16:9)\n";
    int c;
    cin>>c;
    double width;
    double area;
    if (c==1){
        width=(3/4.0)*length;
    }
    else if (c==2){
        width=(9/16.0)*length;
    }
    area=length*width;
    cout<<"\nLength: "<<length;
    cout<<"\nWidth: "<<width;
    cout<<"\nArea: "<<area;
    
    return 0;
}


Output 1



Output 2


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