A piece of wire is to be bent in the form of a rectangle to put around a picture frame. The length of the picture frame is 1.5 times the width. Write a program that prompts the user to input the length of the wire and outputs the length and width of the picture frame

Respuesta :

Answer:

Given Information:

Length of picture frame (L)=1.5*Width of picture frame(W)

Length of wire=Perimeter of rectangle

Perimeter of rectangle=2*(L+W)

Length of wire=2*(L+W)

Length of wire=2*(1.5*W+W)

Length of wire=2*(2.5*W)

Length of wire=5*W

W= Length of wire/5

Question:

Write a program that prompts the user to input the length of the wire and outputs the length and width of the picture frame?

The program is in C++

#include<iostream>

int main() {

  float length;   //variable to store length of rectangle

 float width;     //variable to store width of rectangle

 float length_wire;     //variable to store length of wire

// Taking length of wire as input

  std::cout << "Enter length of wire";

  std::cin >> length_wire;

//Computing length and width of picture frame

 width= length_wire/5;

 length=1.5* width;

 // Printing length and width of picture frame

 std::cout << "Length of wire is:"<<length;

  std::cout << "width of wire is:"<<width;

   return 0;

}

ACCESS MORE
EDU ACCESS
Universidad de Mexico