Answer to Question #266315 in C++ for john

Question #266315

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


1
Expert's answer
2021-11-15T17:28:23-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS