Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int main()
- {
- string s;
- getline(cin, s);
- double budget = stod(s);
- getline(cin, s);
- double count = stod(s);
- string type;
- getline(cin, type);
- double price = 0;
- double discount = 0;
- if (type == "Gsm4e")
- {
- price = 20.5;
- discount = 1;
- }
- else if (type == "Mobifon4e")
- {
- price = 50.75;
- discount = 2;
- }
- else if (type == "Telefon4e")
- {
- price = 115;
- discount = 3;
- }
- if (count > 50)
- {
- discount = discount + 7;
- }
- else if (count > 20)
- {
- discount = discount + 5;
- }
- else if (count > 10)
- {
- discount = discount + 2;
- }
- else
- {
- discount = discount;
- }
- price = price * count;
- price = price - price * discount / 100;
- if (budget >= price)
- {
- printf("The company bought all mobile phones. %.2f leva left.\n", budget - price);
- }
- else
- {
- printf("Not enough money for all mobiles. Company needs %.2f more leva.\n", price - budget);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement