C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 3, Problem 4PE

During each summer, John and Jessica grow vegetables in their backyard and buy seeds and fertilizer from a local nursery. The nursery carries different types of vegetable fertilizers in various bag sizes. When buying a particular fertilizer, they want to know the price of the fertilizer per pound and the cost of fertilizing per square foot. 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 <iostream>

#include <iomanip>

using namespace std;

int main()

{

    double costs

    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;

}

Blurred answer
Students have asked these similar questions
A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity Discount 10 – 19 10% 20 – 49 20% 50 – 99 30% 100 or more 40% Write a program that asks the user to enter the number of packages purchased. The program should then display the full retail price before any discount, the amount of the discount (if any), and the total amount of the purchase after any discount. Do not allow numbers less than 0.
Software SalesA software company sells a package that retails for $99. Quantity discounts are given accordingto the following table:Quantity Discount10–19 10%20–49 20%50–99 30%100 or more 40%Write a program that asks the user to enter the number of packages purchased. The programshould then display he number of packages purchased, the amount of the discount (if any) and the total amount of the purchase after the discount.
A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Qt: 10 -19 Discount: 10% Qt: 20 -49 Discount: 20% Qt: 50 -99 Discount: 30% Qt: 100 or More  Discount: 40% Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.  Python programming question
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY