help with basic program

I'm new to c++ and I'm learning the basics. I've made the following program but there is a logic error somewhere but I don't know where. its probably something silly but I cant find it.

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
double cost;
double area;

double bagsize;

cout << fixed << showpoint << setprecision(2);

cout << "enter the amount of fertilizer, in pounds, " << "in one bag: ";
cin >> bagsize;
cout << endl;

cout "enter the cost of the " << bagsize << " pound fertilizer bag: ";
cin >> cost;
cout << endl;

cout << "enter the area, in square feet, that can be " << "fertilized by one bag: ";
cin >> area
cout >> endl;

cout << "the cost of the fertilizer per pound is: $" << bagsize / cost << endl;
cout << "the cost of fertilizing per square foot is: $" << area / cost << endl;

return 0;
}


Missing operator << after cout in ln.19

Missing semicolon ; after area in ln.24

Using extraction operator >> instead of insertion operator << in ln.25
Last edited on
You have to (atleast in my program) start double variablies with a d.

Example:

Not double area;
but double darea;

and you forgot some <<'s in "cout enter cost of the..."

Oh and i'm new to this too. Having fun?
Last edited on
You don't have to start double variables with a d.

It's just a convention (not even a common one at that) to make it more obvious what the variable is.

Edit: 2^7th post!
Last edited on
I was taught to do this, is it functional without it in all cases?
http://elvis.rowan.edu/~kunkle/24Jan03-Page4.htm

You can follow whatever convention you like, so long as you are consistent, but these are rules that all variable names must follow.
Topic archived. No new replies allowed.