Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Configuration;
- using System.Windows.Forms;
- namespace hil111
- {
- public partial class Form1 : Form
- {
- public static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- string command = string.Empty;
- int foodCount = 0;
- double priceForProducts = 2.50;
- while (command != "Order")
- {
- string food = Console.ReadLine();
- double price = double.Parse(Console.ReadLine());
- foodCount++;
- priceForProducts += price;
- if (priceForProducts > budget)
- {
- Console.WriteLine($"You will exceed the budget if you order this!");
- priceForProducts -= price;
- foodCount--;
- break;
- }
- }
- Console.WriteLine($"You ordered {foodCount} items!");
- Console.WriteLine($"Total: {priceForProducts:F2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement