fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main() {
  6. double cost;
  7. double area;
  8. double bagSize;
  9.  
  10. cout << fixed << showpoint << setprecision(2);
  11.  
  12. cout << "Enter the amount of fertilizer, in pounds, "
  13. << "in one bag: ";
  14. cin >> bagSize;
  15. cout << endl;
  16.  
  17. cout << "Enter the cost of the " << bagSize
  18. << " pound fertilizer bag: ";
  19. cin >> cost;
  20. cout << endl;
  21.  
  22. cout << "Enter the area, in square feet, that can be "
  23. << "fertilized by one bag: ";
  24. cin >> area;
  25. cout << endl;
  26.  
  27. cout << "The cost of the fertilizer per pound is: $"
  28. << bagSize / cost << endl;
  29.  
  30. cout << "The cost of fertilizing per square foot is: $"
  31. << area / cost << endl;
  32. return 0;
  33. }
Success #stdin #stdout 0s 5504KB
stdin
Standard input is empty
stdout
Enter the amount of fertilizer, in pounds, in one bag: 
Enter the cost of the 0.00 pound fertilizer bag: 
Enter the area, in square feet, that can be fertilized by one bag: 
The cost of the fertilizer per pound is: $1.49
The cost of fertilizing per square foot is: $1.00