Last active
January 4, 2020 16:32
-
-
Save kkaraivanov/4195290f4ee55a5b63ba9f403a241024 to your computer and use it in GitHub Desktop.
Vacation - Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Vacation | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int groupPeople = int.Parse(Console.ReadLine()); | |
string groupPeopleType = Console.ReadLine(); | |
string groupPeopleTypeDayStay = Console.ReadLine(); | |
double price = 0; | |
double totalPrice = 0; | |
bool chekDiscount = false; | |
if (groupPeopleTypeDayStay == "Friday") | |
{ | |
if (groupPeopleType == "Students") | |
{ | |
price = 8.45; | |
chekDiscount = groupPeople >= 30 ? true : false; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 10.90; | |
chekDiscount = groupPeople >= 100 ? true : false; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 15; | |
chekDiscount = groupPeople >= 10 && groupPeople <= 20 ? true : false; | |
} | |
} | |
else if (groupPeopleTypeDayStay == "Saturday") | |
{ | |
if (groupPeopleType == "Students") | |
{ | |
price = 9.80; | |
chekDiscount = groupPeople >= 30 ? true : false; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 15.60; | |
chekDiscount = groupPeople >= 100 ? true : false; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 20; | |
chekDiscount = groupPeople >= 10 && groupPeople <= 20 ? true : false; | |
} | |
} | |
else if (groupPeopleTypeDayStay == "Sunday") | |
{ | |
if (groupPeopleType == "Students") | |
{ | |
price = 10.46; | |
chekDiscount = groupPeople >= 30 ? true : false; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 16; | |
chekDiscount = groupPeople >= 10 && groupPeople <= 20 ? true : false; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 22.50; | |
chekDiscount = groupPeople >= 10 && groupPeople <= 20 ? true : false; | |
} | |
} | |
if (chekDiscount) | |
{ | |
if(groupPeopleType == "Students") | |
{ | |
totalPrice = (price * groupPeople) * 0.85; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
totalPrice = price * (groupPeople - 10); | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
totalPrice = (price * groupPeople) * 0.95; | |
} | |
} | |
else | |
{ | |
totalPrice = price * groupPeople; | |
} | |
Console.WriteLine($"Total price: {totalPrice:f2}"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Vacation | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int groupPeople = int.Parse(Console.ReadLine()); | |
string groupPeopleType = Console.ReadLine(); | |
string groupPeopleTypeDayStay = Console.ReadLine(); | |
double totalPrice = 0; | |
bool chekDiscount = false; | |
if ((groupPeople >= 30 && groupPeopleType == "Students") || | |
(groupPeople >= 100 && groupPeopleType == "Business") || | |
(groupPeople >= 10 && groupPeople <= 20 && groupPeopleType == "Regular")) | |
{ | |
chekDiscount = true; | |
} | |
else | |
{ | |
chekDiscount = false; | |
} | |
if (groupPeopleTypeDayStay == "Friday") | |
{ | |
double price = 0; | |
if (groupPeopleType == "Students") | |
{ | |
price = 8.45; | |
totalPrice = chekDiscount ? (price * groupPeople) * 0.85 : price * groupPeople; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 10.90; | |
totalPrice = chekDiscount ? price * (groupPeople - 10) : price * groupPeople; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 15; | |
totalPrice = chekDiscount ? (price * groupPeople) * 0.95 : price * groupPeople; | |
} | |
} | |
else if (groupPeopleTypeDayStay == "Saturday") | |
{ | |
double price = 0; | |
if (groupPeopleType == "Students") | |
{ | |
price = 9.80; | |
totalPrice = chekDiscount ? (price * groupPeople) * 0.85 : price * groupPeople; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 15.60; | |
totalPrice = chekDiscount ? price * (groupPeople - 10) : price * groupPeople; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 20; | |
totalPrice = chekDiscount ? (price * groupPeople) * 0.95 : price * groupPeople; | |
} | |
} | |
else if (groupPeopleTypeDayStay == "Sunday") | |
{ | |
double price = 0; | |
if (groupPeopleType == "Students") | |
{ | |
price = 10.46; | |
totalPrice = chekDiscount ? (price * groupPeople) * 0.85 : price * groupPeople; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 16; | |
totalPrice = chekDiscount ? price * (groupPeople - 10) : price * groupPeople; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 22.50; | |
totalPrice = chekDiscount ? (price * groupPeople) * 0.95 : price * groupPeople; | |
} | |
} | |
Console.WriteLine($"Total price: {totalPrice:f2}"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Vacation | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int groupPeople = int.Parse(Console.ReadLine()); | |
string groupPeopleType = Console.ReadLine(); | |
string groupPeopleTypeDayStay = Console.ReadLine(); | |
double price = 0; | |
double totalPrice = 0; | |
double discountPrice = 0; | |
bool chekDiscount = false; | |
if (groupPeopleTypeDayStay == "Friday") | |
{ | |
if (groupPeopleType == "Students") | |
{ | |
price = 8.45; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 10.90; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 15; | |
} | |
} | |
else if (groupPeopleTypeDayStay == "Saturday") | |
{ | |
if (groupPeopleType == "Students") | |
{ | |
price = 9.80; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 15.60; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 20; | |
} | |
} | |
else if (groupPeopleTypeDayStay == "Sunday") | |
{ | |
if (groupPeopleType == "Students") | |
{ | |
price = 10.46; | |
} | |
else if (groupPeopleType == "Business") | |
{ | |
price = 16; | |
} | |
else if (groupPeopleType == "Regular") | |
{ | |
price = 22.50; | |
} | |
} | |
totalPrice = price * groupPeople; | |
if (groupPeople >= 30 && groupPeopleType == "Students") | |
{ | |
discountPrice = totalPrice * 0.85; | |
chekDiscount = true; | |
} | |
else if (groupPeople >= 100 && groupPeopleType == "Business") | |
{ | |
discountPrice = price * (groupPeople - 10); | |
chekDiscount = true; | |
} | |
else if (groupPeople >= 10 && groupPeople <= 20 && groupPeopleType == "Regular") | |
{ | |
discountPrice = totalPrice * 0.95; | |
chekDiscount = true; | |
} | |
Console.WriteLine(chekDiscount ? $"Total price: {discountPrice:f2}" : $"Total price: {totalPrice:f2}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment