alexivanov2003

Computer store

Sep 18th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Computer_Store
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string input = Console.ReadLine();
  10.             double totalPrice = 0;
  11.  
  12.  
  13.             while (input != "special" && input != "regular")
  14.             {
  15.                 double price = double.Parse(input);
  16.  
  17.                 if (price < 0)
  18.                 {
  19.                     Console.WriteLine("Invalid price!");
  20.                 }
  21.                 else
  22.                 {
  23.                     totalPrice += price;
  24.  
  25.                 }
  26.                 input = Console.ReadLine();
  27.             }
  28.  
  29.             double taxes = totalPrice * 0.2;
  30.             double finalPrice = taxes + totalPrice;
  31.  
  32.             if (input == "special")
  33.             {
  34.                 finalPrice = finalPrice - (finalPrice*0.1);
  35.  
  36.             }
  37.             if (finalPrice == 0d)
  38.             {
  39.                 Console.WriteLine("Invalid order!");
  40.             }
  41.             else
  42.             {
  43.                 Console.WriteLine("Congratulations you've just bought a new computer!");
  44.                 Console.WriteLine($"Price without taxes: {totalPrice:F2}$ ");
  45.                 Console.WriteLine($"Taxes: {taxes:f2}$");
  46.                 Console.WriteLine("-----------");
  47.                 Console.WriteLine($"Total price: {finalPrice:f2}$");
  48.             }
  49.            
  50.         }
  51.     }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment