Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <math.h>
- using namespace std;
- int main()
- {
- double needSum;
- cin >> needSum;
- cin.ignore();
- double earnedMoney = 0;
- //команда -> име на коктейл или парти
- //stop -> команда е "Party!"
- //продължаваме -> команда != "Party!"
- string command;
- getline(cin, command);
- while (command != "Party!") {
- //коктейл
- string cocktail = command;
- int count;
- cin >> count;
- cin.ignore();
- //печалбата от коктейла = цена на коктейла * броя на коктейлите -> добавим към спечелените пари
- int moneyForCocktails = count * cocktail.length();
- if (moneyForCocktails % 2 == 1) {
- double finalPriceOrder = moneyForCocktails - 0.25 * moneyForCocktails; //0.75 * moneyForCocktails
- earnedMoney += finalPriceOrder;
- }
- else {
- earnedMoney += moneyForCocktails;
- }
- if (earnedMoney >= needSum) {
- cout << "Target acquired." << endl;
- break;
- }
- getline(cin, command);
- }
- cout.setf(ios::fixed);
- cout.precision(2);
- if (command == "Party!") {
- cout << "We need " << needSum - earnedMoney << " leva more." << endl;
- }
- cout << "Club income - " << earnedMoney << " leva." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment