Advertisement
MartinGerov

Untitled

May 30th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Configuration;
  10. using System.Windows.Forms;
  11.  
  12.  
  13. namespace hil111
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public static void Main(string[] args)
  18. {
  19. double budget = double.Parse(Console.ReadLine());
  20. string command = string.Empty;
  21. int foodCount = 0;
  22. double priceForProducts = 2.50;
  23.  
  24. while (command != "Order")
  25. {
  26. string food = Console.ReadLine();
  27. double price = double.Parse(Console.ReadLine());
  28. foodCount++;
  29. priceForProducts += price;
  30.  
  31. if (priceForProducts > budget)
  32. {
  33. Console.WriteLine($"You will exceed the budget if you order this!");
  34. priceForProducts -= price;
  35. foodCount--;
  36. break;
  37. }
  38. }
  39. Console.WriteLine($"You ordered {foodCount} items!");
  40. Console.WriteLine($"Total: {priceForProducts:F2}");
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement