Advertisement
MartinGeorgiev

01. Computer Store

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