# Please Help With Vista C++ Win32 Console



## cemcem318 (Oct 24, 2007)

*Please Help With Visual studio C++ Win32 Console*

I have to write a program that will compute the amount someone will have to pay for a parcel of land.

Input: the length and width in feet.
Price per Acre.

Extra information:
1 Acre= 43560 sq. ft

Calculation:
Total area in square feet
Total Acreage.
Total Amount of Sale

Output:
Total area in square feet.
Total acreage
Total Amount of Sale.


right now all i have is-

#include "stdafx.h"
#include <iostream>
Using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

int L=Length,
W=Width,
A=43,560,
P=Price Per Acre,
Square footage=Sq_feet.

cout<<" Enter The Length"
cin>>"L";
cout<<"Enter the Width"
cin>>"W";
cout<<"Enter the Price Per Acre"
cin>>"P";
cout>>"Enter 43,560",
cin>>"A";
Sq_feet=L*W;

cout<<"The Square Footage is"<<Sq_feet<<endl;


I am totally lost- what I have done does not seem right but I just done understand and I have been working on C++ in class for a few days and this particular solution for hours now- I think I am supposed to make up a number to put in maybe for width? but I dont know...can somebody please help??


----------



## Bookworm99 (Jun 5, 2007)

Ok. Firstly, unless you're using a seriously different type of C++, you declared the variables wrong. Ints cannot be strings, only numbers. It looks like you were trying to name your variables then set them - you don't set the name to [variable]=name, you just use the name as your variable. Instead of w = width, use width = [number]. Try this: 


```
//use instead of your variables
int length, width, pricePerAcre, sqFeet;
```
Also, with cout, you need to add << endl; to end that line, or at least add a << ""; to close the line. Always add semicolons at the end of a command or line. Example: 


```
//BAD 
cout << "Enter the Lenght"

//GOOD 
cout << "Enter the Length." << endl;
```
When using cin, don't put the variable name in quotes. That confuses the compiler. 


```
//BAD
cin >> "Length"

//GOOD
cin >> length;
```
Finally, you absolutely MUST close your main function. Like so: 


```
//BAD MAIN
int _tmain(int argc, _TCHAR* argv[])
{
//code

//GOOD MAIN
int _tmain(int argc, _TCHAR* argv[])
{
//code
//add this for cross-compiler compatability
system("PAUSE"); 
}
```
Now, like I said, if this is totally unfamiliar to you, what you're doing is definitely not C++. At least, not like I know it...


----------



## cemcem318 (Oct 24, 2007)

okay i understand...so now i have something more like...



#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int Length,
Width,
Price;
cout<<"Enter The Length";
cin>> Length,
cout<<"Enter The Width",
cin>> Width;
cout<<"Enter The Price";




return 0;
}



but what i dont understand is what to make the amount equal to


----------



## Bookworm99 (Jun 5, 2007)

That's much better. It should compile on your computer now.

Just a suggestion - use the word 'code' (no quotes) within [] to create a box for your code. Close it with '/code' (no quotes, also in []). 

Now, the only other thing you'd need to do is add spacing - while it should work fine without it, it will make your code neater and easier to read. Comments are also your friend. That, and the area that says 


```
int length, 
width, 
price;
```
should read


```
int length, width, price;
```
Again, that shouldn't make a difference, but makes the code more legible. 

What you want to do is find the price per square foot, right? Well, you'd need a variable for square feet, which would be length * width. Then the price (which you could make fixed, or dependent on the length - like, if it's longer then 6 feet or wider then 10 feet, that's $40 extra).

Also, forgive me, but I have to ask: Is someone teaching you this, or are you teaching yourself?


----------



## cemcem318 (Oct 24, 2007)

thanks for your help....well im taking a class on it but i just dont understand anything im being taught so ive been reading through the tutorials on cplusplus.com and just trying to figure it out by myself because I thought once I figured out how to do the first assignment I would be able to figure any of them out- but i have been struggling with all of them!


----------



## Bookworm99 (Jun 5, 2007)

Well, I hate to say it, bu that's why you really need to read over the stuff you get assigned and ask the teacher. I'm sure s/he'll be able to help you more then I can. Good luck.


----------

