Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _01._Computer_Store
- {
- class Program
- {
- static void Main (string[]args)
- {
- string partPrice = Console.ReadLine ();
- double currentPrice = 0;
- double totalPrice = 0;
- double discont = 0;
- while (partPrice != "regular")
- {
- if (partPrice == "special")
- {
- discont = totalPrice * 0.12;
- break;
- }
- currentPrice = double.Parse (partPrice);
- if (currentPrice < 0)
- {
- Console.WriteLine ("Invalid price!");
- currentPrice = 0;
- }
- totalPrice += currentPrice;
- partPrice = Console.ReadLine();
- }
- double priceWithTax = (totalPrice*1.2) - discont;
- if (priceWithTax == 0)
- {
- 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: {(totalPrice*0.2):f2}$");
- Console.WriteLine ($"-----------");
- Console.WriteLine ($"Total price: {priceWithTax:f2}$");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement