Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CruiseShip
- {
- class Program
- {
- static void Main(string[] args)
- {
- string destination = Console.ReadLine();
- string cabinType = Console.ReadLine();
- int overnights = int.Parse(Console.ReadLine());
- double dayPrice = 0;
- if (destination == "Mediterranean")
- {
- if (cabinType == "standard cabin")
- {
- dayPrice = 27.50;
- }
- else if (cabinType == "cabin with balcony")
- {
- dayPrice = 30.20;
- }
- else
- {
- dayPrice = 40.50;
- }
- }
- else if (destination == "Adriatic")
- {
- if (cabinType == "standard cabin")
- {
- dayPrice = 22.99;
- }
- else if (cabinType == "cabin with balcony")
- {
- dayPrice = 25.00;
- }
- else
- {
- dayPrice = 34.99;
- }
- }
- else
- {
- if (cabinType == "standard cabin")
- {
- dayPrice = 23.00;
- }
- else if (cabinType == "cabin with balcony")
- {
- dayPrice = 26.60;
- }
- else
- {
- dayPrice = 39.80;
- }
- }
- double totalSum = dayPrice * 4 * overnights;
- if (overnights > 7)
- {
- totalSum *= 0.75;
- }
- Console.WriteLine($"Annie's holiday in the {destination} sea costs {totalSum:f2} lv.");
- }
- }
- }
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- using System;
- namespace CruiseShip
- {
- class Program
- {
- static void Main(string[] args)
- {
- string destination = Console.ReadLine();
- string cabinType = Console.ReadLine();
- int overnights = int.Parse(Console.ReadLine());
- double dayPrice =
- destination == "Mediterranean" ?
- (cabinType == "standard cabin" ? 27.50 : cabinType == "cabin with balcony" ? 30.20 : 40.50) :
- destination == "Adriatic" ?
- (cabinType == "standard cabin" ? 22.99 : cabinType == "cabin with balcony" ? 25.00 : 34.99) :
- (cabinType == "standard cabin" ? 23.00 : cabinType == "cabin with balcony" ? 26.60 : 39.80);
- double totalSum = dayPrice * 4 * overnights * (overnights > 7 ? 0.75 : 1);
- Console.WriteLine($"Annie's holiday in the {destination} sea costs {totalSum:f2} lv.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement