Advertisement
Stan0033

Untitled

Mar 13th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.BackgroundColor = ConsoleColor.DarkCyan;
  14. Console.ForegroundColor = ConsoleColor.Black;
  15. Console.Title = "Zadacha 1";
  16. Console.OutputEncoding = Encoding.UTF8;
  17. //-------------------------------------
  18. Console.Clear();
  19. Console.SetWindowPosition(0, 0);
  20. //--------------------------------
  21. Console.WriteLine("Задача: конвертор от USD към BGN. Напишете exit когато приключите.\n");
  22. Console.Write("USD: ");
  23. //--------------------------------
  24. double usd;
  25. double bgn;
  26.  
  27. //--------------------------------
  28.  
  29. string message = Console.ReadLine();
  30.  
  31. bool IsNumber;
  32.  
  33. //--------------------------------
  34.  
  35. while (message != "exit"){
  36. message = Console.ReadLine();
  37. Console.Write("USD: ");
  38. // check if theh message is a number
  39.  
  40. IsNumber = double.TryParse(message, out usd);
  41. // it it's a number do the conversion and display
  42.  
  43. if (IsNumber){
  44.  
  45. bgn = usd * 1.79549;
  46.  
  47. string temp = String.Format("{0:0.00}", bgn);
  48. bgn = Convert.ToDouble(temp);
  49.  
  50. Console.WriteLine("{0} щатски долара са {1} лева", usd, bgn);
  51. }
  52.  
  53.  
  54.  
  55.  
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement