//Logic errors.
#include <iostream>
#include <iomanip>
usingnamespace 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;
}
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.
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
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$