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