Anonim_999

2

Dec 22nd, 2022
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp27
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.Write($"Сумма покупки: ");
  10.             string userInput = Console.ReadLine();
  11.             int value;
  12.  
  13.             if (int.TryParse(userInput,out value))
  14.             {
  15.                 if (value >= 10000 && value <= 30000)
  16.                     Console.WriteLine($"Скидка 5%. Сумма: {GetPriceDiscount(value,5)}");
  17.                 else if (value > 30000)
  18.                     Console.WriteLine($"Скидка 10%. Сумма: {GetPriceDiscount(value,10)}");
  19.                 else
  20.                     Console.WriteLine($"Скидка 0%. Сумма: {value}");
  21.             }
  22.             else
  23.             {
  24.                 Console.WriteLine("Ошибка ввода!");
  25.             }
  26.         }
  27.  
  28.         private static float GetPriceDiscount(float value, float discountValue)
  29.         {
  30.             discountValue /= 100;
  31.             float dicountPrice = value - (value * discountValue);
  32.             return dicountPrice;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment