When I run the code, it doesn't calculate and it doesn't show the calculations. Wondering if my variables or something else is wrong or maybe in the wrong place.
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 Question_3_Retail_Price_Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
decimal costPrice = 0;
decimal markUpRateA = 0.19m;
decimal markUpRateB = 0.14m;
decimal markUpRateC = 0.12m;
decimal markUpRate = 0m;
decimal markUpTotal = 0;
decimal totalCost = 0;
// Add the items to ListBox 1
listBox1.Items.Add("Markup Rate =");
listBox1.Items.Add("Markup Total =");
listBox1.Items.Add("Total Cost =");
try
{
// Read the cost price from the user
costPrice = decimal.Parse(textBox1.Text);
}
catch (System.Exception excep )
{
MessageBox.Show(excep.Message);
}
if (costPrice <= 50)
{
// Calculate the value of the product
costPrice = (costPrice / 100) * markUpRateA;
}
else if (costPrice >= 50 && costPrice < 100)
{
// Calculate the value of the product
costPrice = (costPrice / 100) * markUpRateB;
}
else if (costPrice < 100)
{
// Calculate the value of the product
costPrice = (costPrice / 100) * markUpRateC;
}
else if (markUpRate == markUpTotal)
{
// Calculate the total monetary amount
markUpTotal = costPrice * markUpRate;
}
else
{
// Calculate the Total Cost of the product
totalCost = costPrice + markUpTotal;
}
// Output the total Cost
MessageBox.Show("Total Cost is: €" + totalCost);
}
}
}
Need some help figuring this out! Thanks in advance!