Advertisement
JOHNYTHEWINNER

Bar

Jan 22nd, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6.  
  7. int main()
  8. {
  9.     double whiskeyprice;
  10.     cin >> whiskeyprice;
  11.     double beer;
  12.         do
  13.     {
  14.         cin.clear();
  15.         cin >> beer;
  16.     }
  17.     while (cin.bad() || beer < 0 || beer> 10000);
  18.     double wine;
  19.     do
  20.     {
  21.         cin.clear();
  22.         cin >> wine;
  23.     } while (cin.bad() || wine < 0 || wine> 10000);
  24.     double brandy;
  25.     do
  26.     {
  27.         cin.clear();
  28.         cin >> brandy;
  29.     } while (cin.bad() || brandy< 0 || brandy > 10000);  
  30.     double whiskey;
  31.     do
  32.     {
  33.         cin.clear();
  34.         cin >> whiskey;
  35.     } while (cin.bad() || whiskey < 0 || whiskey> 10000);
  36.     double brandyprice = whiskeyprice / 2;
  37.     double wineprice = brandyprice *0.6;
  38.     double beerprice = brandyprice * 0.2;
  39.     double sum = beerprice*beer + wineprice*wine + brandyprice*brandy + whiskeyprice*whiskey;
  40.    
  41.     cout << fixed << setprecision(2) << sum << endl;
  42.    
  43.    
  44.     return 0;
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement