The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost, and the area, in square feet, that can be covered by the bag. The program should output the desired result. However, the program contains logic errors
#include <iostream>
using namespace std;
int main()
{
double price;
double area;
double bag_size;
cout << fixed << showpoint << setprecision(2);
cout << "Enter the amount of fertilizer, in pounds, "
<< "in one bag: ";
cin >> bag_size;
cout << "\n";
cout << "Enter the price of the " << bag_size << " pound fertilizer bag: ";
cin >> price;
cout << "\n";
cout << "Enter the area, in square feet, that can be "
<< "fertilized by one bag: ";
cin >> area;
cout << "\n";
cout << "The price of the fertilizer per pound is: $" << price / bag_size << "\n";
cout << "The price of fertilizing per square foot is: $" << price / area << "\n";
return 0;
}
Comments
Leave a comment