#1

For my computer programming class, I have to write a couple programs, but I'm lost on the first one. The problem says:

Write a program that reads in the length and width of a rectangular yard (in meters) and the length and width of a rectangular of a rectangular house (in meters) placed in the yard. Your program should compute the time (in minutes) required to cut the lawn around the house. Assume the mowing rate is in square meters per minutes is entered as a data item.

So far I have :

//Pg 111 Prob 3

//My name

#include <iostream>

using namespace std;

int main ()

{

And that's all I can figure out. Please help. By the way this is in C++

Write a program that reads in the length and width of a rectangular yard (in meters) and the length and width of a rectangular of a rectangular house (in meters) placed in the yard. Your program should compute the time (in minutes) required to cut the lawn around the house. Assume the mowing rate is in square meters per minutes is entered as a data item.

So far I have :

//Pg 111 Prob 3

//My name

#include <iostream>

using namespace std;

int main ()

{

And that's all I can figure out. Please help. By the way this is in C++

#2

So what you're asking is for someone to tell you the code to the whole problem? You've done none of it yourself

Surely it's just using cin to read in values for the length and width, then a simple calculation to work out the time taken to cut the lawn.

So start with something like this, perhaps?:

Surely it's just using cin to read in values for the length and width, then a simple calculation to work out the time taken to cut the lawn.

So start with something like this, perhaps?:

```
//only needs one value since they're rectangular
int houseWidth;
int lawnWidth;
cout << "Enter the width of the house:";
cin >> houseWidth;
cout << "Enter the width of the lawn:";
cin >> lawnWidth;
```

*Last edited by Kilobyte at Sep 19, 2010,*

#3

So what you're asking is for someone to tell you the code to the whole problem? You've done none of it yourself

Surely it's just using cin to read in values for the length and width, then a simple calculation to work out the time taken to cut the lawn.

So start with something like this, perhaps?:`//only needs one value since they're rectangular`

int houseWidth;

int lawnWidth;

cout << "Enter the width of the house:";

cin >> houseWidth;

cout << "Enter the width of the lawn:";

cin >> lawnWidth;

Oh I see. And no I don't need someone to write it all for me. Just need a little help figuring it out.

EDIT: Wait why onely 1 value? Don't I need the length too?

*Last edited by izbbass at Sep 19, 2010,*

#4

Fair enough. Well the first step would be figuring out what variables you need to get an input for (so in this case, lawn width, house width and mowing rate), what output you need (time for mowing), and how you reach that output with the variables you have.

Simples

Simples

#5

Fair enough. Well the first step would be figuring out what variables you need to get an input for (so in this case, lawn width, house width and mowing rate), what output you need (time for mowing), and how you reach that output with the variables you have.

Simples

Not really :/

The mowing rate is what trips me up

#6

For my computer programming class, I have to write a couple programs, but I'm lost on the first one. The problem says:

Write a program that reads in the length and width of a rectangular yard (in meters) and the length and width of a rectangular of a rectangular house (in meters) placed in the yard. Your program should compute the time (in minutes) required to cut the lawn around the house. Assume the mowing rate is in square meters per minutes is entered as a data item.

So far I have ://Pg 111 Prob 3

//My name

#include <iostream>

using namespace std;

int main ()

{

And that's all I can figure out. Please help. By the way this is in C++

BTW, why no } for your main?

Seriously though, surely you've learnt some basics, right? If not then I recommend finding a new course, and looking for tutorials online.

#7

BTW,why no } for your main?

Seriously though, surely you've learnt some basics, right? If not then I recommend finding a new course, and looking for tutorials online.

That comes at the end right?

And we've only had 2 classes and I can tell no one in the class will be able to figure it out. And that's why I'm here...

#8

```
{
int penis_size;
cout<<"sup dawg";
cin>>penis_size;
cout<<"lolololololo, only"<<penis_size/9999;
}
```

Hope that helps.

#9

bejaysus.... calculate the area that the house takes up by multiplying it's width by it's length... take that away from the area of the yard(found by multiplying it's length by it's height)

the result of that is the size of the lawn, all you need to do now is display the size of the lawn with minutes after it

lawnSize+"mins";

done.

This is a common question, google is your friend. If it's only the first question and your having trouble with it... maybe next time pay attention in class >.> or talk to your teacher/lecturer and explain your having some trouble, ask if he can recommend a good book, a great site for programming questions is www.dreamincode.net I used it about 2 years ago and it was handy to start off with. There's also some decent tutorials on there.

The basis of all programming is problem solving. Google how to read in values from the keyboard, break the problem presented to you into small managable chunks. Work through each little chunk to get the whole thing working. Most people just read the whole question and go "oh shittttttt" don't stress yourself take it easy and step through it by breaking things up. ;D

the result of that is the size of the lawn, all you need to do now is display the size of the lawn with minutes after it

lawnSize+"mins";

done.

This is a common question, google is your friend. If it's only the first question and your having trouble with it... maybe next time pay attention in class >.> or talk to your teacher/lecturer and explain your having some trouble, ask if he can recommend a good book, a great site for programming questions is www.dreamincode.net I used it about 2 years ago and it was handy to start off with. There's also some decent tutorials on there.

The basis of all programming is problem solving. Google how to read in values from the keyboard, break the problem presented to you into small managable chunks. Work through each little chunk to get the whole thing working. Most people just read the whole question and go "oh shittttttt" don't stress yourself take it easy and step through it by breaking things up. ;D

*Last edited by Ice Master at Sep 19, 2010,*

#10

So, what you need to do, then, is this:

Get input of the length/width of the yard, length/width of the house, and the mowing rate.

Work out the area of the yard, and the area of the house.

Subtract the area of the house from the area of the yard, which gives you the total area that will be mown.

Divide the total area to be mown (in square metres) by the mowing rate, giving you the time taken to mow the lawn.

(ex. if the yard was 10 sq. metres, and you could mow at 2 sq. metres per minute, it would take you 5 minutes to mow the lawn).

I think this is what you would need to do, but if I'm wrong, please correct me!

This is just pseudocode, if you want help converting this to actual code, feel free to PM me any questions.

Hope this helps

Get input of the length/width of the yard, length/width of the house, and the mowing rate.

Work out the area of the yard, and the area of the house.

Subtract the area of the house from the area of the yard, which gives you the total area that will be mown.

Divide the total area to be mown (in square metres) by the mowing rate, giving you the time taken to mow the lawn.

(ex. if the yard was 10 sq. metres, and you could mow at 2 sq. metres per minute, it would take you 5 minutes to mow the lawn).

I think this is what you would need to do, but if I'm wrong, please correct me!

This is just pseudocode, if you want help converting this to actual code, feel free to PM me any questions.

Hope this helps

#11

I'm giving up on this today. Football is on. My class is tomorrow and I'm sure I won't be the only one with it not done

#12

I'm giving up on this today. Football is on. My class is tomorrow and I'm sure I won't be the only one with it not done

-_-

#13

Jesus fu

These websites are your best friends:

http://www.google.com/

http://www.cplusplus.com/reference/

**cking Christ man. At least make an effort to write code...**These websites are your best friends:

http://www.google.com/

http://www.cplusplus.com/reference/