pgiovanni

Untitled

Jul 29th, 2021
966
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string>
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main () {
  8.  
  9.     string inputTmp;
  10.    
  11.     string priceTmp;
  12.     float difference;
  13.     vector<int> coinCount {0,0,0,0};
  14.  
  15.    
  16.  
  17.     cin >> inputTmp;
  18.     cin >> priceTmp;
  19.  
  20.  
  21.     float input = stof(inputTmp);
  22.     float price = stof(priceTmp);
  23.  
  24.  
  25.  
  26.     if (price < input) {
  27.        
  28.         difference = input - price;
  29.         difference = difference * 100;
  30.         cout << difference << endl;
  31.        
  32.         do {
  33.             if (difference >= 100) {
  34.                 coinCount[3] = coinCount[3] + 4;
  35.                 difference  = difference - 100;
  36.                 cout << "first statment worked" << endl;
  37.             }  
  38.             else if (difference < 100 && difference >= 25) {
  39.                 coinCount[3] = coinCount[3] +1;
  40.                 difference = difference - 25;
  41.                 cout << "second statement worked" << endl;
  42.             }
  43.             else if (difference < 25 && difference >= 10) {
  44.                 coinCount[2] = coinCount[2] + 1;
  45.                 difference = difference - 10;
  46.                 cout << "third statement" << endl;
  47.             }
  48.             else if (difference < 10 && difference >= 5) {
  49.                 coinCount[1] = coinCount[1] + 1;
  50.                 difference = difference - 5;
  51.                 cout << "fourth statement" << endl;
  52.             }
  53.             else if (difference < 5 && difference > 0) {
  54.                 coinCount[0] = coinCount[0] +  1;
  55.                 difference = difference - 1;
  56.                 cout << "fifth statement" << endl;
  57.             }
  58.        
  59.         } while (difference > 0);
  60.  
  61.        
  62.  
  63.  
  64.     }
  65.  
  66.     //for (int i =0; i < coinCount.size(); i++)
  67.     //    cout << coinCount[i] << endl;
  68.  
  69.     for (int i = 0; i < coinCount.size(); i ++)
  70.  
  71.         cout << coinCount[i] << endl;
  72.  
RAW Paste Data