Advertisement
Aliendreamer

hotel conditional loops

May 16th, 2018
474
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.  
  3.  
  4.      public  class Program
  5.     {
  6.         public static void Main(string[] args)
  7.         {
  8.            
  9.             string month=Console.ReadLine();
  10.             int nights = int.Parse(Console.ReadLine());
  11.            
  12.             decimal studioPrice=0M;
  13.             decimal doublePrice=0M;
  14.             decimal suitePrice=0M;
  15.            
  16.             bool freeFivePercentDiscount=nights>7;
  17.             bool tenFifteenPercentDiscount=nights>14;
  18.            
  19.             switch(month)
  20.             {
  21.                 case"May":
  22.                
  23.                     studioPrice = 50 * nights;
  24.                     doublePrice = 65 * nights;
  25.                     suitePrice = 75 * nights;
  26.                
  27.                 if(freeFivePercentDiscount)studioPrice *=0.95M;
  28.                 break;
  29.                
  30.                 case"June":
  31.                  
  32.                     studioPrice = 60 * nights;
  33.                     doublePrice = 72 * nights;
  34.                     suitePrice = 82 * nights;
  35.                    
  36.                 if (tenFifteenPercentDiscount)doublePrice *= 0.90M;
  37.                    
  38.                 break;
  39.                
  40.                 case"July":
  41.                
  42.                     studioPrice = 68 * nights;
  43.                     doublePrice = 77 * nights;
  44.                     suitePrice = 89 * nights;
  45.                     if(tenFifteenPercentDiscount)suitePrice *=0.85M;
  46.                  
  47.                 break;
  48.                
  49.                 case"August":
  50.                
  51.                     studioPrice = 68 * nights;
  52.                     doublePrice = 77 * nights;
  53.                     suitePrice = 89 * nights;
  54.                
  55.                     if (tenFifteenPercentDiscount)suitePrice *= 0.85M;
  56.                            
  57.                 break;
  58.                
  59.                 case"September":
  60.                  
  61.                     studioPrice = 60*nights;
  62.                     doublePrice = 72 * nights;
  63.                     suitePrice = 82 * nights;
  64.                    
  65.                     if(tenFifteenPercentDiscount)doublePrice *=0.90M;              
  66.                     if(freeFivePercentDiscount)studioPrice=60*newNights;                               
  67.                 break;
  68.                
  69.                 case"October":
  70.                
  71.                     studioPrice = 50*nights;
  72.                     doublePrice = 65 * nights;
  73.                     suitePrice = 75 * nights;
  74.                    
  75.                 if(freeFivePercentDiscount)
  76.                 {
  77.                        studioPrice=50*newNights;
  78.                         studioPrice*=0.95M;
  79.                 }
  80.                
  81.                break;
  82.                
  83.                 case"December":
  84.                
  85.                     suitePrice = 89 * nights;
  86.                     studioPrice = 68 * nights;
  87.                     doublePrice = 77 * nights;
  88.                                
  89.                     if(tenFifteenPercentDiscount) suitePrice*=0.85M;
  90.                    
  91.                 break;
  92.             }
  93.            
  94.             Console.WriteLine("Studio: {0:f2} lv.", studioPrice);
  95.             Console.WriteLine("Double: {0:f2} lv.", doublePrice);
  96.             Console.WriteLine("Suite: {0:f2} lv.", suitePrice);
  97.         }
  98.              
  99.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement