Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MidExamComputerStoreExercise1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command = Console.ReadLine();
- double priceWithoutTax = 0;
- while(command != "regular" && command != "special")
- {
- double price = double.Parse(command);
- if (price < 0)
- {
- Console.WriteLine("Invalid price!");
- command = Console.ReadLine();
- continue;
- }
- priceWithoutTax += price;
- command = Console.ReadLine();
- }
- if (priceWithoutTax == 0)
- {
- Console.WriteLine("Invalid order!");
- return;
- }
- double taxes = 0.20 * priceWithoutTax;
- double allPrice = priceWithoutTax + taxes;
- if(command == "special")
- {
- allPrice = allPrice - allPrice* 0.10;
- }
- Console.WriteLine($"Congratulations you've just bought a new computer!\nPrice without taxes: {priceWithoutTax:F2}$\nTaxes: {taxes:F2}$\n-----------\nTotal price: {allPrice:F2}$");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement