Doing this project for school.. am not new to computers, but am new to programming.
I keep getting an error stating that "boardFootPrice " is an unassigned local variable.. Could use some advice.
here is my code:
I keep getting an error stating that "boardFootPrice " is an unassigned local variable.. Could use some advice.
here is my code:
Code:
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
private int boardLength;
double totalSales;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
panel1.Visible = false;
Oak.Checked = true;
}
private void button3_Click(object sender, EventArgs e)
{
const double OAK_PRICE = 6.00,
MAPLE_PRICE = 7.40,
WALNUT_PRICE = 8.50;
int boardLength, boardWidth, boardThickness;
double boardFeet, boardFootPrice, totalCost;
if (Oak.Checked)
boardFootPrice = OAK_PRICE;
if (Maple.Checked)
boardFootPrice = MAPLE_PRICE;
if (Walnut.Checked)
boardFootPrice = WALNUT_PRICE;
boardLength = Convert.ToInt32 (textBox1.Text);
boardWidth = Convert.ToInt32 (textBox2.Text);
boardThickness = Convert.ToInt32 (textBox3.Text);
boardFeet = boardLength * (boardWidth / 12.0) * boardThickness;
totalCost = boardFeet*boardFootPrice;
totalSales += totalCost;
label7.Text = string.Format ("{0 2:c6}",boardFeet);
label8.Text = string.Format ("{0 2:c6}",boardFootPrice);
label9.Text = string.Format ("{0 2:c6}",totalCost);
label11.Text = string.Format("{0 2:c6}", totalSales);
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox1.Focus();
Oak.Checked = true;
button3.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}
Comment