Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Exercises_Condition_Loop
- {
- class Program
- {
- static void Main(string[] args)
- {
- }
- private static void NeighbourWars()
- {
- var peshoDamage = int.Parse(Console.ReadLine());
- var goshoDamage = int.Parse(Console.ReadLine());
- //
- var peshoHealth = 100;
- var goshoHealth = 100;
- //
- var round = 0;
- while (true)
- {
- if (round % 2 == 0)
- {
- round++;
- goshoHealth -= peshoDamage;
- if (goshoHealth <= 0)
- {
- Console.WriteLine($"Pesho won in {round}th round.");
- break;
- }
- else
- {
- Console.Write("Pesho used Roundhouse kick and reduced ");
- Console.WriteLine($"Gosho to {goshoHealth} health.");
- }
- }
- else
- {
- round++;
- peshoHealth -= goshoDamage;
- if (peshoHealth <= 0)
- {
- Console.WriteLine($"Gosho won in {round}th round.");
- break;
- }
- else
- {
- Console.Write("Gosho used Thunderous fist and reduced");
- Console.WriteLine($" Pesho to {peshoHealth} health.");
- }
- }
- if (round % 3 == 0 && (peshoHealth > 0 || goshoHealth > 0))
- {
- peshoHealth += 10;
- goshoHealth += 10;
- }
- }
- }
- private static void Macig_Number()
- {
- char a = char.Parse(Console.ReadLine());
- char b = char.Parse(Console.ReadLine());
- char stop = char.Parse(Console.ReadLine());
- //
- for (char i = a; i <= b; i++)
- {
- for (char ii = a; ii <= b; ii++)
- {
- for (char iii = a; iii <= b; iii++)
- {
- if (i != stop && ii != stop && iii != stop)
- {
- Console.Write($"{i}{ii}{iii} ");
- }
- }
- }
- }
- }
- private static void GameOfNumbers()
- {
- var num1 = int.Parse(Console.ReadLine());
- var num2 = int.Parse(Console.ReadLine());
- var stop = int.Parse(Console.ReadLine());
- var isFoundNum = true;
- var combination = 0;
- var a = 0;
- var b = 0;
- var sum = 0;
- for (int i = num1; i <= num2; i++)
- {
- for (int ii = num1; ii <= num2; ii++)
- {
- combination++;
- if (i + ii == stop)
- {
- a = i;
- b = ii;
- sum = stop;
- isFoundNum = false;
- }
- }
- }
- if (isFoundNum)
- {
- Console.WriteLine($"{combination} combinations - neither equals {stop}");
- }
- else
- {
- Console.WriteLine($"Number found! {a} + {b} = {sum}");
- }
- }
- private static void Test_Numbers()
- {
- var num1 = int.Parse(Console.ReadLine());
- var num2 = int.Parse(Console.ReadLine());
- var stop = int.Parse(Console.ReadLine());
- //
- var product = 0;
- var temp = 0;
- var combination = 0;
- for (int i = num1; i >= 1; i--)
- {
- for (int ii = 1; ii <= num2; ii++)
- {
- if (product > stop)
- {
- break;
- }
- else
- {
- temp = 3 * (i * ii);
- product += temp;
- combination++;
- }
- }
- }
- Console.WriteLine($"{combination} combinations");
- if (product < stop)
- {
- Console.WriteLine($"Sum: {product}");
- }
- else
- {
- Console.WriteLine($"Sum: {product} >= {stop}");
- }
- }
- private static void Five_Diff_Numbers()
- {
- var a = int.Parse(Console.ReadLine());
- var b = int.Parse(Console.ReadLine());
- var isThereInterval = true;
- for (int i = a; i <= b; i++)
- {
- for (int ii = a; ii < b; ii++)
- {
- for (int iii = a; iii < b; iii++)
- {
- for (int iiii = a; iiii < b; iiii++)
- {
- for (int iiiii = a; iiiii <= b; iiiii++)
- {
- if (a <= i && i < ii && ii < iii && iii < iiii && iiii < iiiii && iiiii <= b)
- {
- Console.WriteLine($"{i} {ii} {iii} {iiii} {iiiii}");
- isThereInterval = false;
- }
- }
- }
- }
- }
- }
- if (isThereInterval)
- {
- Console.WriteLine("No");
- }
- }
- private static void Num_Triangle()
- {
- var n = int.Parse(Console.ReadLine());
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= i; j++)
- {
- Console.Write(i + " ");
- }
- Console.WriteLine();
- }
- }
- private static void Count_Integers()
- {
- var count = 0;
- while (true)
- {
- var data = Console.ReadLine();
- try
- {
- if (int.Parse(data) % 2 == 0 || int.Parse(data) % 2 != 0)
- {
- count++;
- }
- }
- catch (Exception)
- {
- Console.WriteLine(count);
- break;
- }
- }
- }
- private static void Calories()
- {
- var n = int.Parse(Console.ReadLine());
- var total = 0;
- for (int i = 0; i < n; i++)
- {
- string product = Console.ReadLine().ToLower();
- if (product == "cheese")
- {
- total += 500;
- }
- else if (product == "tomato sauce")
- {
- total += 150;
- }
- else if (product == "salami")
- {
- total += 600;
- }
- else if (product == "pepper")
- {
- total += 50;
- }
- }
- Console.WriteLine($"Total calories: {total}");
- }
- private static void Cake()
- {
- string ingredient = Console.ReadLine();
- var count = 0;
- while (ingredient != "Bake!")
- {
- count++;
- Console.WriteLine($"Adding ingredient {ingredient}.");
- ingredient = Console.ReadLine();
- }
- Console.WriteLine($"Preparing cake with {count} ingredients.");
- }
- private static void Interval_Numbers()
- {
- var a = int.Parse(Console.ReadLine());
- var b = int.Parse(Console.ReadLine());
- //
- var small = 0;
- var big = 0;
- //
- if (a > b)
- {
- big = a;
- small = b;
- }
- else
- {
- big = b;
- small = a;
- }
- for (int i = small; i <= big; i++)
- {
- Console.WriteLine(i);
- }
- }
- private static void Word_In_Plural()
- {
- var word = Console.ReadLine();
- var newWord = "";
- if (word.EndsWith("ch") || word.EndsWith("o") || word.EndsWith("s") || word.EndsWith("sh") || word.EndsWith("x") || word.EndsWith("z"))
- {
- word += "es";
- }
- else if (word.EndsWith("y"))
- {
- word = word.Remove(word.Length - 1);
- word += "ies";
- }
- else
- {
- word += "s";
- }
- Console.WriteLine(word);
- }
- private static void Hotel()
- {
- var month = Console.ReadLine();
- var nightsCount = int.Parse(Console.ReadLine());
- //
- var studio = 0.0;
- var doub = 0.0;
- var suit = 0.0;
- //
- if (month == "May" || month == "October")
- {
- studio = 50;
- doub = 65;
- suit = 75;
- }
- if (month == "June" || month == "September")
- {
- studio = 60;
- doub = 72;
- suit = 82;
- }
- if (month == "July" || month == "December" || month == "August")
- {
- studio = 68;
- doub = 77;
- suit = 89;
- }
- bool isFree = true;
- if ((month == "May" || month == "October") && nightsCount > 7)
- {
- studio *= 0.95;
- }
- if ((month == "June" || month == "September") && nightsCount > 14)
- {
- doub *= 0.90;
- }
- if ((month == "July" || month == "December" || month == "August") && nightsCount > 14)
- {
- suit *= 0.85;
- }
- if ((month == "September" || month == "October") && nightsCount > 7)
- {
- nightsCount--;
- isFree = false;
- }
- if (isFree)
- {
- studio *= nightsCount;
- doub *= nightsCount;
- suit *= nightsCount;
- }
- if (isFree == false)
- {
- studio *= nightsCount;
- doub *= (nightsCount + 1);
- suit *= (nightsCount + 1);
- }
- //
- Console.WriteLine($"Studio: {studio:f2} lv.");
- Console.WriteLine($"Double: {doub:f2} lv.");
- Console.WriteLine($"Suite: {suit:f2} lv.");
- }
- private static void Reataurant_Discount()
- {
- var groupSize = int.Parse(Console.ReadLine());
- var pack = Console.ReadLine();
- //
- var hall = "";
- var price = 0.0;
- var pricePack = 0.0;
- //
- if (groupSize <= 120)
- {
- if (groupSize <= 50)
- {
- hall = "Small Hall";
- price = 2500;
- }
- else if (groupSize <= 100)
- {
- hall = "Terrace";
- price = 5000;
- }
- else if (groupSize <= 120)
- {
- hall = "Great Hall";
- price = 7500;
- }
- var total = 0.0;
- if (pack == "Normal")
- {
- pricePack = 500;
- total = price + pricePack;
- total *= 0.95;
- }
- else if (pack == "Gold")
- {
- pricePack = 750;
- total = price + pricePack;
- total *= 0.9;
- }
- else if (pack == "Platinum")
- {
- pricePack = 1000;
- total = price + pricePack;
- total *= 0.85;
- }
- total /= groupSize;
- Console.WriteLine($"We can offer you the {hall}");
- Console.WriteLine($"The price per person is {total:f2}$");
- }
- else
- {
- Console.WriteLine("We do not have an appropriate hall.");
- }
- }
- private static void Choose_Drink_2_0()
- {
- //The {profession} has to pay {totalPrice}.
- var profession = Console.ReadLine();
- var quatity = int.Parse(Console.ReadLine());
- double[] price = { 0.7, 1.0, 1.7, 1.2 };
- var total = 0.0;
- var drink = "";
- if (profession == "Athlete")
- {
- drink = "Water";
- total = price[0] * quatity;
- }
- else if (profession == "Businessman" || profession == "Businesswoman")
- {
- drink = "Coffee";
- total = price[1] * quatity;
- }
- else if (profession == "SoftUni Student")
- {
- drink = "Beer";
- total = price[2] * quatity;
- }
- else
- {
- drink = "Tea";
- total = price[3] * quatity;
- }
- Console.WriteLine($"The {profession} has to pay {total:f2}.");
- }
- private static void Choose_DRink()
- {
- var profession = Console.ReadLine();
- var drink = "";
- if (profession == "Athlete")
- {
- drink = "Water";
- }
- else if (profession == "Businessman" || profession == "Businesswoman")
- {
- drink = "Coffee";
- }
- else if (profession == "SoftUni Student")
- {
- drink = "Beer";
- }
- else
- {
- drink = "Tea";
- }
- Console.WriteLine(drink);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement