Advertisement
Kyojin96

Untitled

Aug 9th, 2022
816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Computer_Store
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double totalPrice = 0;
  10.            
  11.             do {
  12.                 string input = Console.ReadLine();
  13.                 if (input == "special" || input == "regular")
  14.                 {
  15.                     break;
  16.                 }
  17.                
  18.                 double price = 0;
  19.                
  20.                 bool valid = double.TryParse(input, out price);
  21.                
  22.                 if (!valid || price <= 0)
  23.                 {
  24.                     Console.WriteLine("Invalid price!");
  25.                     continue;
  26.                 }
  27.                
  28.                 totalPrice += price;
  29.             } while (true);
  30.  
  31.             Console.WriteLine(totalPrice);
  32.  
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement