Question: The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, and the area, in

The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, 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. Find and correct the logic errors so that the program works properly.
//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;
}
Format your output with setprecision(2) to ensure the proper number of decimals for testing!
Task #01: Cost per pound and per square foot correctly output
Test Feedback:
Status: FAILED!
Check: 1
Test: Cost per pound and per square foot correctly output test 1
Reason: Unable to find '['0.36','0.04']' in the program's output.
Enter the amount of fertilizer, in pounds, in one bag:
Enter the cost of the 33.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: $2.75
The cost of fertilizing per square foot is: $25.00
.
Error : AssertionError - Unable to find a number close enough to 0.36(+/-0.00) in the program's output.
Timestamp: 2024-05-2202:36:35.189281
Status: FAILED!
Check: 2
Test: Cost per pound and per square foot correctly output test 2
Reason: Unable to find '['0.80','0.07']' in the program's output.
Enter the amount of fertilizer, in pounds, in one bag:
Enter the cost of the 10.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.25
The cost of fertilizing per square foot is: $15.01
.
Error : AssertionError - Unable to find aThe following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, 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. Find and correct the logic errors so that the program works properly.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!