Answer to Question #293806 in C++ for katy

Question #293806

Write a Program: Daily Supplement Cost



Your horse has to have 1 ounce of probiotic supplement a day. You can buy it per



pound, as a 10 lb pail at a 10% discount, or as a 20 lb pail at a 15% discount. Your



the goal is to produce formatted output showing the daily cost for each buying



option. You should ask the user to enter the price per lb.


your output should look similar to this:




Enter price per lb: $18.50



Buying option 1 lb 5 lb 10 lb



Cost per day ($) 1.16 1.04 0.98







1
Expert's answer
2022-02-04T07:59:24-0500
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    const int N=3;
    int pails[N] = {1, 10, 20};
    int discount[N] = {0, 10, 15};
    double price;

    cout << "Enter price per lb: $";
    cin >> price;

    cout << "Buying option   ";
    for (int i=0; i<N; i++) {
        cout << " " << pails[i] << " lb";
    }
    cout << endl;

    cout << "Cost per day ($) ";
    for (int i=0; i<N; i++) {
        double cost;
        cost = price * (1 - discount[i]/100.0);
        cout << fixed << setprecision(2) << cost / 16 << "  ";
    }

}

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