PROGRAMMING ERROR PLEASE HELP
// im writting code and im stuck idk what else to try ive googled put breakpoints. please help here is my code im using visual studio 2010. thanks. here is my code... my errors exist in the 'if' statements in the bottom where i have the counter to see if the user is checking the boxes. more specifically the vitaminpack and the energy booster. code reads "invalid token 'if' in class, struct, or interface member declaration. and on the first extrasInterger++ it tells me the same thing except the ++ instead of the if. please help.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace juicebarform
{
public partial class JuiceBarForm : Form
{
//Declare class variable.
private decimal itemPriceDecimal, totalOrderDecimal, totalSalesDecimal;
private int drinksInteger, ordersInteger;
public JuiceBarForm()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void addToOrderButton_Click(object sender, EventArgs e)
{
//Add the current item price and quantity to the order
if (noSizeRadioButton.Checked)
{
MessageBox.Show("you must select a drink size.", "missing required entry");
}
else
{
try
{
int quantityInteger = int.Parse(quantityTextBox.Text);
if (quantityInteger != 0)
{
drinksInteger += quantityInteger;
totalOrderDecimal += itemPriceDecimal * quantityInteger;
orderCompleteButton.Enabled = true;
//Resset defaults for next item
noSizeRadioButton.Checked = true;
fruitJuiceRadioButton.Checked = true;
VitaminPackCheckBox.Checked = false;
energyBoosterCheckBox.Checked = false;
ladiesCheckBox.Checked = false;
itemPriceTextBox.Clear();
quantityTextBox.Text = "1";
}
else
{
MessageBox.Show("Please enter a quantity.", "Missing required entry");
}
}
catch (FormatException)
{
MessageBox.Show("Invalid quantity.", "data entry error");
quantityTextBox.Focus();
quantityTextBox.SelectAll();
}
}
}
private void orderCompleteButton_Click(object sender, EventArgs e)
{
//order complete, add to summary and clear order.
//Check if the last time was added to the total.
if(itemPriceTextBox.Text != "")
{
DialogResult responseDialogResult;
string messageString = "Current item not recorded. Add to order?";
responseDialogResult = MessageBox.Show(messageString,"Verify Last Drink Purchase",MessageBoxButtons.YesNo,MessageBoxIcon.Q uestion);
if(responseDialogResult == DialogResult.Yes)
{
addToOrderButton_Click(sender, e);
}
}
// Display amount due.
string dueString = "amount due" + totalOrderDecimal.ToString("C");
MessageBox.Show(dueString, "Order Complete");
//Add to summary totals
ordersInteger++;
totalSalesDecimal += totalOrderDecimal;
//reset buttons and total for new order.
summaryReportButton.Enabled =true;
orderCompleteButton.Enabled = false;
totalOrderDecimal = 0m;
}
private void summaryReportButton_Click(object sender, EventArgs e)
{
// DIsplay the summary information in a message box
string summaryString = "Drinks sold: " + drinksInteger.ToString()
+ ordersInteger.ToString() + "\n\n" + "Total Sales: "
+ totalSalesDecimal.ToString("C");
MessageBox.Show(summaryString, "Juice Bar Sales Summary",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
private void exitButton_Click(object sender, EventArgs e)
{
//End the application
this.Close();
}
private void twelveOunceRadioButton_CheckedChanged(object sender, EventArgs e)
{
//Calculate and display the price for the selected item
// Handles all the check boxes and radio buttons
int extrasInteger = 0;
if(twelveOunceRadioButton.Checked)
{
itemPriceDecimal = 3m;
}
else
if(sixteenOunceRadioButton.Checked)
{
itemPriceDecimal = 3.5m;
}
else
if(twentyOunceRadioButton.Checked)
itemPriceDecimal = 4m;
}
int extrasInteger = 0;
if (VitaminPackCheckBox.Checked)
{
extrasInteger++;
}
if (energyBoosterCheckBox.Checked)
{
extrasInteger++;
}
if(ladiesCheckBox.Checked)
{
extrasInteger++;
}
itemPriceDecimal += extrasInteger * .5m; // 50 cents for each extra.
itemPriceDecimal.Text = itemPriceDecimal.ToString("C");
}
Last edited by jordan_2324; April 6th, 2013 at 03:55 PM..
|