Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- using namespace std;
- double milk_price,
- pasta_price,
- meat_price,
- threshold;
- unsigned short milk_amount,
- pasta_amount,
- meat_amount,
- min_discount_percentage,
- max_discount_percentage;
- cout << "Insert milk_price, pasta_price, meat_price, threshold: ";
- cin >>
- milk_price >>
- pasta_price >>
- meat_price >>
- threshold;
- cout << "milk_amount, pasta_amount, meat_amount, min_discount_percentage, max_discount_percentace: ";
- cin >>
- milk_amount >>
- pasta_amount >>
- meat_amount >>
- min_discount_percentage >>
- max_discount_percentage;
- double
- milk_expence = (double)milk_amount * milk_price,
- pasta_expence = (double)pasta_amount * pasta_price,
- meat_expence = (double)meat_amount * meat_price;
- double total_expence =
- milk_expence + pasta_expence + meat_expence;
- double discounted;
- if ( total_expence > threshold )
- discounted = total_expence - ( ( max_discount_percentage / (double)100 ) * total_expence );
- else
- discounted = total_expence - ( ( min_discount_percentage / (double)100 ) * total_expence );
- cout << "Milk: " << milk_expence << endl
- << "Pasta: " << pasta_expence << endl
- << "Meat: " << meat_expence << endl
- << "Total: " << total_expence << endl
- << "Discounted: " << discounted << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement