Sep 4, 2016 at 11:29pm UTC
Hey, guys. I need help with this question: 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 then outputs the length and the width of the picture frame.
I'm not sure if I should code something that has got to do with the perimeter. Thanks for your time!
Last edited on Sep 5, 2016 at 1:56am UTC
Sep 5, 2016 at 12:36am UTC
ok so I've written this with some help from others. Do you think it represents what the question is trying to ask?
#include <iostream>
using namespace std;
int main()
{
double length;
double width;
cout << "Input the length of the wire:";
cin >> length;
cout << endl;
width = length / 1.5;
cout << "length = " << length << endl;
cout << "width = " << width << endl;
return 0;
}
Sep 5, 2016 at 1:58am UTC
Ok so a quick question.
How did you get to width = LW/5?
and how did you get to Width = 0.2 * LW?
and finally, how is length = 0.3?
Sep 5, 2016 at 6:15pm UTC
Let LW be length of wire input by user.
The perimeter of rectangle will be equal of LW.
LW = 2(l + w)
But , l = 1.5w......(Equation 1)
LW = 2(1.5w + w)
LW = 5w
Therefore
w= LW/5 = 0.2LW
Substituting value of w in equation 1.
l = 1.5(0.2LW)
l= 0.3 LW
Sep 6, 2016 at 12:15am UTC
Ok. So I got this. What do you think?
#include <iostream>
using namespace std;
int main()
{
double length;
double width;
double Lengthofwire;
cout << "Input the length of the wire:";
cin >> Lengthofwire;
cout << endl;
// formula to get length and width for picture frame
width = Lengthofwire / 5;
length = 1.5 * width;
cout << "length = " << length << endl;
cout << "width= " << width << endl;
return 0;
}