Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string stageOfTheChampionship, typesOfTickets;
- getline(cin, stageOfTheChampionship);
- cin >> typesOfTickets;
- int ticketCount;
- cin >> ticketCount;
- string selfieWithTheTrophy;
- cin >> selfieWithTheTrophy;
- double ticketPrice = 0;
- if (stageOfTheChampionship == "Quarter final") {
- if (typesOfTickets == "Standard") {
- ticketPrice = 55.50;
- }
- else if (typesOfTickets == "Premium") {
- ticketPrice = 105.20;
- }
- else if (typesOfTickets == "VIP") {
- ticketPrice = 118.90;
- }
- }
- else if (stageOfTheChampionship == "Semi final") {
- if (typesOfTickets == "Standard") {
- ticketPrice = 75.88;
- }
- else if (typesOfTickets == "Premium") {
- ticketPrice = 125.22;
- }
- else if (typesOfTickets == "VIP") {
- ticketPrice = 300.40;
- }
- }
- else if (stageOfTheChampionship == "Final") {
- if (typesOfTickets == "Standard") {
- ticketPrice = 110.10;
- }
- else if (typesOfTickets == "Premium") {
- ticketPrice = 160.66;
- }
- else if (typesOfTickets == "VIP") {
- ticketPrice = 400.00;
- }
- }
- double totalPrice = ticketPrice * ticketCount;
- if (totalPrice > 4000) {
- totalPrice *= 0.75;
- selfieWithTheTrophy = "N";
- }
- else if (totalPrice > 2500) {
- totalPrice *= 0.90;
- }
- if (selfieWithTheTrophy == "Y") {
- totalPrice += ticketCount * 40;
- }
- printf("%.2f\n", totalPrice);
- return 0;
- }
- Решение с тернарен оператор:
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string stageOfTheChampionship, typesOfTickets;
- getline(cin, stageOfTheChampionship);
- cin >> typesOfTickets;
- int ticketCount;
- cin >> ticketCount;
- string selfieWithTheTrophy;
- cin >> selfieWithTheTrophy;
- double totalPrice =
- (stageOfTheChampionship == "Quarter final" ? (typesOfTickets == "Standard" ? 55.50 : typesOfTickets == "Premium" ? 105.20 : 118.90) :
- stageOfTheChampionship == "Semi final" ? (typesOfTickets == "Standard" ? 75.88 : typesOfTickets == "Premium" ? 125.22 : 300.40) :
- (typesOfTickets == "Standard" ? 110.10 : typesOfTickets == "Premium" ? 160.66 : 400.00)) * ticketCount;
- selfieWithTheTrophy = totalPrice > 4000 ? "No" : selfieWithTheTrophy;
- totalPrice = totalPrice * (totalPrice > 4000 ? 0.75 : totalPrice > 2500 ? 0.90 : 1) + (selfieWithTheTrophy == "Y" ? ticketCount * 40 : 0);
- printf("%.2f\n", totalPrice);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement