Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ComputerStore
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- string command = Console.ReadLine();
- double totalPricesWithoutTaxes = 0;
- double totalTaxes = 0;
- double totalPricesWithTaxes = 0;
- while (command!= "special" && command!="regular")
- {
- double priceWithoutTax = double.Parse(command);
- if (priceWithoutTax <= 0)
- {
- Console.WriteLine($"Invalid price!");
- command = Console.ReadLine();
- continue;
- }
- totalTaxes += 0.20 * priceWithoutTax;
- totalPricesWithoutTaxes += priceWithoutTax;
- command = Console.ReadLine();
- }
- if (command == "special")
- {
- totalPricesWithTaxes = (totalPricesWithoutTaxes + totalTaxes) - 0.1 * (totalPricesWithoutTaxes + totalTaxes);
- if (totalPricesWithTaxes == 0)
- {
- Console.WriteLine("Invalid order!");
- return;
- }
- Console.WriteLine($"Congratulations you've just bought a new computer!");
- Console.WriteLine($"Price without taxes: {totalPricesWithoutTaxes:f2}$");
- Console.WriteLine($"Taxes: {totalTaxes:f2}$");
- Console.WriteLine("-----------");
- Console.WriteLine($"Total price: {totalPricesWithTaxes:f2}$");
- }
- else if (command == "regular")
- {
- totalPricesWithTaxes = (totalPricesWithoutTaxes + totalTaxes);
- if (totalPricesWithTaxes == 0)
- {
- Console.WriteLine("Invalid order!");
- return;
- }
- Console.WriteLine($"Congratulations you've just bought a new computer!");
- Console.WriteLine($"Price without taxes: {totalPricesWithoutTaxes:f2}$");
- Console.WriteLine($"Taxes: {totalTaxes:f2}$");
- Console.WriteLine("-----------");
- Console.WriteLine($"Total price: {totalPricesWithTaxes:f2}$");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement