skipter

C# Fundamentals - Hotel / if statement

Jun 2nd, 2017
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.02 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 ConsoleApp9
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string month = Console.ReadLine();
  14.             int nights = int.Parse(Console.ReadLine());
  15.  
  16.             double studio = 0;
  17.             double doubleRoom = 0;
  18.             double suite = 0;
  19.  
  20.             if (month.Equals("May") || month.Equals("October"))
  21.             {
  22.                
  23.                 studio = 50;
  24.                 doubleRoom = 65;
  25.                 suite = 75;
  26.                 if (nights > 7)
  27.                 {
  28.                     studio = studio - (studio * 0.05);
  29.                 }
  30.  
  31.             } else if (month.Equals("June") || month.Equals("September"))
  32.             {
  33.                 studio = 60;
  34.                 doubleRoom = 72;
  35.                 suite = 82;
  36.                 if ( nights > 14)
  37.                 {
  38.                     doubleRoom = doubleRoom - (doubleRoom * 0.10);
  39.                 }
  40.  
  41.             } else if (month.Equals("July") || month.Equals("August") || month.Equals("December"))
  42.             {
  43.                 studio = 68;
  44.                 doubleRoom = 77;
  45.                 suite = 89;
  46.                 if (nights > 14)
  47.                 {
  48.                     suite = suite - (suite * 0.15);
  49.                 }
  50.             }
  51.             double studioTotalPrice = nights * studio;
  52.             double doubleRoomTotalPrice = doubleRoom * nights;
  53.             double suiteTotalPrice = suite * nights;
  54.             if (month.Equals("October") && nights > 7 || month.Equals("September") && nights > 7)
  55.             {
  56.                 // one night is free
  57.                 studioTotalPrice = studioTotalPrice - studio;
  58.             }
  59.             Console.WriteLine($"Studio: {studioTotalPrice:F2} lv.");
  60.             Console.WriteLine($"Double: {doubleRoomTotalPrice:F2} lv.");
  61.             Console.WriteLine($"Suite: {suiteTotalPrice:F2} lv.");
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment