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
#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 << " ";
}
}
Comments
Leave a comment