Question

The screen size of a TV is given by the length of the rectangular diagonal. Traditional...

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.

Instructions

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

import java.util.*;

public class Main
{
   public static void main(String[] args) {
   Scanner s = new Scanner(System.in);
       System.out.print("Input length of the diagonal(in inches) of the screen: ");
       double length = s.nextDouble();
      
       System.out.println("Which type of TVs dimension would you like to see: ");
       System.out.println("1. Traditional TV area");
       System.out.println("2. LCD TV area");
       System.out.println("3. Both type TV area");
       System.out.print("Enter your choice: ");
       int choice = s.nextInt();
      
       if(choice == 1)
       {
       double width = (double)3/4 * length;
       double area = length * width;
       System.out.println("Traditional TV:");
       System.out.println("Screen length - "+ length);
       System.out.println("Screen width - "+ width);
       System.out.println("Screen area - "+ area);
       }
       else if(choice == 2)
       {
       double lwidth = (double)9/16* length;
       double larea = length * lwidth;
       System.out.println("LCD TV:");
       System.out.println("Screen length - "+ length);
       System.out.println("Screen width - "+ lwidth);
       System.out.println("Screen area - "+ larea);
       }
       else if(choice == 3)
       {
       double tradwidth = (double)3/4 * length;
       double tradarea = length * tradwidth;
       System.out.println("Traditional TV:");
       System.out.println("Screen length - "+ length);
       System.out.println("Screen width - "+ tradwidth);
       System.out.println("Screen area - "+ tradarea);
      
       System.out.println();
       double lcdwidth = (double)9/16 * length;
       double lcdArea = length * lcdwidth;
       System.out.println("LCD TV:");
       System.out.println("Screen length - "+ length);
       System.out.println("Screen width - "+ lcdwidth);
       System.out.println("Screen area - "+ lcdArea);
       }
       else{
       System.out.println("Sorry, invalid choice!!");
       }
      
      
   }
}

Output:

Add a comment
Know the answer?
Add Answer to:
The screen size of a TV is given by the length of the rectangular diagonal. Traditional...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C Program 2. Write a program which defines a (hollow rectangular) prism as a...

    Write a C Program 2. Write a program which defines a (hollow rectangular) prism as a structure consisting of: length(int) width(int) height(int) • weight(double) • contents(char [25]) Initialize the structure with default values 10, 6, 3, 4.5, and "Best Jewelry" Ask user for new length, width and height and then display Contents, volume, and sum of dimensions

  • Examine the following class diagram, additional information and answer the questions that follow screenType: char screenSize:...

    Examine the following class diagram, additional information and answer the questions that follow screenType: char screenSize: int resolution: string price: double standard: boo1 TV(char= 'L', int= 50, string=" HD", double= 600, bool = true ) setorder )void displayvoid getPrice() :double etstandard (:bool; Additional Information Meth tv 〔 char = 'L,, ユnt S0, string ="HD", double -600, bol - true | Constructor with default values. The tional arguments are screenType. screenSize, resolution, price and standard Set the data members accordingly. [Note:...

  • Write, compile, and test a class that displays your first name on the screen. Save the...

    Write, compile, and test a class that displays your first name on the screen. Save the class as Name. Write, compile, and test a class that displays your full name, street address and city, on three separate lines on the screen. Save the class as Address. Write a java program which add two numbers and print the result on screen. Save the class as Add2. Write a java program which accepts two numbers from user multiply them and print the...

  • Construct a C++ class named Rectangle that has floating-point data members named length and width.  The class...

    Construct a C++ class named Rectangle that has floating-point data members named length and width.  The class should have a zero-argument constructor that initializes each data member to 0. It should have member functions named calcPerimeter() and calcArea() that calculate the perimeter and area of a rectangle respectively, a member function setLength() and setWidth() to set the length and width, member functions getLength() and getWidth() to return the length and width, and a member function showData() that displays the rectangle’s length,...

  • Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape...

    Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape from the information supplied. Write pseudocode to solve this problem and write a Python program that asks the user to input the required information for a shape and then calculates the area of the shape. Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1...

  • The length of a new rectangular playing field is 8 yards longer than double the width....

    The length of a new rectangular playing field is 8 yards longer than double the width. If the perimeter of the rectangular playing field is 286 yards, what are its dimensions? The width is yards. The length is yards Enter your in each of the answer boxes o Type here to search FO F 4 Eac 4 F2 40 A 0 $ 4 % 5 6 7 8 2 3 0 P c Y T R E W a Tab...

  • solve it with Java please Write a Java program that prompts the user to input length...

    solve it with Java please Write a Java program that prompts the user to input length and width of a shape. If length is equal to width, call a method to calculate the area of the shape and send only one side as parameter to this method. This meth return the area of the shape. If length is not equal to width, call a method to calculate the area of the shape and send both width and length as parameters...

  • C++ Programming Question for an intro course Complete a program that determines how many brownies will...

    C++ Programming Question for an intro course Complete a program that determines how many brownies will fit in a baking pan of a specified size. The program should do the following correctly:  Prompt the user to enter the length and width (in inches) of a baking pan.  Compute the surface area of the bottom of the pan.  Compute how many small brownies the pan will hold if each one is cut with a 1”x1” square bottom. ...

  • 5.13 Program: Drawing a half arrow (Python 3) This zyLab activity is the traditional programming assignment,...

    5.13 Program: Drawing a half arrow (Python 3) This zyLab activity is the traditional programming assignment, typically requiring a few hours over a week. The previous section provides warm up exercises intended to help a student prepare for this programming assignment. This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to...

  • ******** IN JAVA ********* I have a program that I need help debugging. This program should...

    ******** IN JAVA ********* I have a program that I need help debugging. This program should ask a user to input 3 dimensions of a rectangular block (length, width, and height), and then perform a volume and surface area calculation and display the results of both. It should only be done using local variables via methods and should have 4 methods: getInput, volBlock, saBlock, and display (should be void). I have most of it written here: import java.util.*; public class...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT