### homework help

the problem states that the program will run but there are logical errors, im simply too noob to find them can someone help?

 ``12345678910111213141516171819202122232425262728293031323334`` ``````//Logic errors. #include #include 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; }``````
Your maths is wrong on line 32. And line 29.
Last edited on
Hello CloudFF7,

An observation, if the program compiles and runs that would indicate that there are no logic errors in your code, so the only other possibility would be in the math.

Andy
Hello CloudFF7,

If I corrected the math correctly this should help you understand what the math should be:

 ``` Enter the amount of fertilizer, in pounds, in one bag: 50 Enter the cost of the 50.00 pound fertilizer bag: 25 Enter the area, in square feet, that can be fertilized by one bag: 10 The cost of the fertilizer per pound is: \$0.50 The cost of fertilizing per square foot is: \$2.50 ```

Hope that helps,

Andy
Letâ€™s say you can buy 2 pounds for 6\$.
That means 1 pound = 3\$
So you have to do cost/bagsize
13 pounds = 39\$
If you want to have 1 pound you have to divide it by 13
13/13 and 39/13
1 pound = 3\$
Topic archived. No new replies allowed.