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