simonradev

Vacation

Mar 11th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Vacation
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //            •   Първият ред – броят възрастни хора.Цяло число в интервала[1…100]
  14.             //•   Вторият ред – броят ученици. Цяло число в интервала[1… 100]
  15.             //•   Третият ред – броят нощувки. Цяло число в интервала[1... 60]
  16.             //•   Четвъртият ред – вид транспорт – “train”, “bus”, “boat” или “airplane”
  17.  
  18.             int oldPeopleCount = int.Parse(Console.ReadLine());
  19.             int studentsCount = int.Parse(Console.ReadLine());
  20.             int sleepovers = int.Parse(Console.ReadLine());
  21.             string transportType = Console.ReadLine().ToLower();
  22.  
  23.             double oldPeopleTransportCosts = 0.0;
  24.             double studentsTransportCosts = 0.0;
  25.             if (transportType == "train")
  26.             {
  27.                 oldPeopleTransportCosts = oldPeopleCount * 24.99;
  28.                 studentsTransportCosts = studentsCount * 14.99;
  29.  
  30.                 if (oldPeopleCount + studentsCount >= 50)
  31.                 {
  32.                     oldPeopleTransportCosts *= 0.5;
  33.                     studentsTransportCosts *= 0.5;
  34.                 }
  35.             }
  36.             else if (transportType == "bus")
  37.             {
  38.                 oldPeopleTransportCosts = oldPeopleCount * 32.50;
  39.                 studentsTransportCosts = studentsCount * 28.50;
  40.             }
  41.             else if (transportType == "boat")
  42.             {
  43.                 oldPeopleTransportCosts = oldPeopleCount * 42.99;
  44.                 studentsTransportCosts = studentsCount * 39.99;
  45.             }
  46.             else if (transportType == "airplane")
  47.             {
  48.                 oldPeopleTransportCosts = oldPeopleCount * 70.0;
  49.                 studentsTransportCosts = studentsCount * 50.0;
  50.             }
  51.  
  52.             double totalTransportCosts = (oldPeopleTransportCosts + studentsTransportCosts) * 2.0;
  53.             double totalSleepoverCosts = sleepovers * 82.99;
  54.  
  55.             double totalCostsWithoutComission = totalTransportCosts + totalSleepoverCosts;
  56.             double comission = totalCostsWithoutComission * 0.1;
  57.  
  58.             double totalCosts = totalCostsWithoutComission + comission;
  59.  
  60.             Console.WriteLine($"{totalCosts:f2}");
  61.         }
  62.     }
  63. }
Add Comment
Please, Sign In to add comment