#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++
Quote by UntilISleep
You have excellent taste in literature, dear sir

Quote by Primus2112
You have excellent taste in video games, good sir.

Quote by GbAdimDb5m7
You have terrible taste in signatures, idiotic sir.

kkoo
#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?:

//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;

You are standing in an open field west of a white house, with a boarded front door.
There is a small mailbox here.



Steam: | PSN: Zeroxxed | Twitter:
Last edited by Kilobyte at Sep 19, 2010,
#3
Quote by Kilobyte
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?
Quote by UntilISleep
You have excellent taste in literature, dear sir

Quote by Primus2112
You have excellent taste in video games, good sir.

Quote by GbAdimDb5m7
You have terrible taste in signatures, idiotic sir.

kkoo
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

You are standing in an open field west of a white house, with a boarded front door.
There is a small mailbox here.



Steam: | PSN: Zeroxxed | Twitter:
#5
Quote by Kilobyte
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
Quote by UntilISleep
You have excellent taste in literature, dear sir

Quote by Primus2112
You have excellent taste in video games, good sir.

Quote by GbAdimDb5m7
You have terrible taste in signatures, idiotic sir.

kkoo
#6
Quote by izbbass
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.
Sunn O))):
Quote by Doppelgänger
You could always just sleep beside your refrigerator.

Guitar:
- Ibanez S670FM w/ JB
- Fender 'Lite Ash' Stratocaster
- Fender '72 Deluxe Telecaster
- Arbiter LP Jr. Doublecut
Amp:
- Laney VC15

'72 Tele Appreciation Group
RIP DIO
#7
Quote by Simsimius


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...
Quote by UntilISleep
You have excellent taste in literature, dear sir

Quote by Primus2112
You have excellent taste in video games, good sir.

Quote by GbAdimDb5m7
You have terrible taste in signatures, idiotic sir.

kkoo
#8

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

Hope that helps.
Quote by Pleasure2kill
The truth is, Muslims never apologized for their faith having something to do with the attacks on 9/11.
#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
Lepracauns Forever!!!!!!!!!!!!
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
Tell me, who is this?
It's Mr. Lemon...
What are you doing here?
I'm off to the cupboard, where I keep the bodies...
Bad Mr. Lemon, bad lemon.
#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
Quote by UntilISleep
You have excellent taste in literature, dear sir

Quote by Primus2112
You have excellent taste in video games, good sir.

Quote by GbAdimDb5m7
You have terrible taste in signatures, idiotic sir.

kkoo
#12
Quote by izbbass
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

-_-
Lepracauns Forever!!!!!!!!!!!!