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.Windows.Forms;
- namespace Snack_Machine
- {
- public partial class frmSnackMachine : Form
- {
- double price = 0.00;
- public frmSnackMachine()
- {
- InitializeComponent();
- }
- private void btnChips_Click(object sender, EventArgs e)
- {
- price = price + 0.50;
- lblMoneyOwed.Text = price.ToString();
- }
- private void btnSourCandy_Click(object sender, EventArgs e)
- {
- price = price + 0.75;
- lblMoneyOwed.Text = price.ToString();
- }
- private void btnChocolate_Click(object sender, EventArgs e)
- {
- price = price + 1.00;
- lblMoneyOwed.Text = price.ToString();
- }
- private void btnClearChoices_Click(object sender, EventArgs e)
- {
- price = 0.00;
- lblMoneyOwed.Text = price.ToString();
- }
- private void btnInsertMoney_Click(object sender, EventArgs e)
- {
- double givenAmount = double.Parse(txtTypeAmount.Text);
- price = price - givenAmount;
- lblMoneyOwed.Text = price.ToString();
- if (givenAmount < price)
- MessageBox.Show("Please insert more money");
- if (givenAmount >= price)
- MessageBox.Show("Snack dispensing. Thank you and come again!");
- }
- private void btnGetChange_Click(object sender, EventArgs e)
- {
- double change = price;
- MessageBox.Show("Change Dispensed");
- price = price - price;
- lblMoneyOwed.Text = price.ToString();
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment