Advertisement
Spocoman

08. Orders

Nov 17th, 2023
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. void orderSum(string product, int quantity) {
  7.     double productPrice =
  8.         product == "coffee" ? 1.50 :
  9.         product == "water" ? 1.00 :
  10.         product == "coke" ? 1.40 :
  11.         product == "snacks" ? 2.00 : 0;
  12.  
  13.     cout << fixed << setprecision(2) << productPrice * quantity << endl;
  14. }
  15.  
  16. int main() {
  17.     string product;
  18.     cin >> product;
  19.  
  20.     int quantity;
  21.     cin >> quantity;
  22.  
  23.     orderSum(product, quantity);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement