Leo94 Leo94 - 6 months ago 73
C++ Question

how to write this program for C++

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 the 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.

I've tried to start it

#include <iostream>

using namespace std;

int main() {

double length;
double width;

cout << "Input the length of the wire:";
cin >> length;
cout << endl;

return 0;



Well you know that the length of the wire. So let's call that L.

Width will be fW and length of frame will be fL.

Then you have:

2*fW + 2*fL = L.

fL = 1.5*fW

2*fW + 2*(1.5*fW) = L

L = 5*fW

fW = L/5.

So basically you know that the width of the frame will be length of wire divided by 5. And length will be 1.5 times that.