I try to write this program but how I think math?
A general store has the following offer.
If you shop for a minimum of 200 $ will receive a 5% discount on the full amount. If you shop for at least
400 $, you get 10% off the full amount
Write a program that calculates how much you will pay based on the full amount of the
items you want to buy.
If the total amount is greater than $399, multiply it by .9 to get the total after a 10% discount. Otherwise, if the amount is greater than $199, multiply it by .95 for a 5% discount. Otherwise, don't make any changes:
// Apply discounts
if (total > 399)
total *= .9;
else if (total > 199)
total *= .95;
Yep it is definetly the Parse that s causing the problem. Your variable buff always returns false and doesn t go on with the code. one more thing. after setting the result variable to 0 you are not using it anymore so just write at the end instead of result.ToString() --txtDiscount.Text = total.ToString();
public partial class Form2 : Form
maskedTextBox1.Mask = "$0000.00";
maskedTextBox1.TabIndex = 0;
private void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
private void button1_Click(object sender, EventArgs e)
total = (double)maskedTextBox1.ValidateText();
if (total >=400)
total *= .9;
else if (total >= 200)
total *= .95;
txtDiscount.Text = total.ToString("####.##",CultureInfo.InvariantCulture);
Any character entered that isn't a digit or if the decimal is put in the wrong place the value will clear. But this can be handled any number of different ways. The only obvious caveat with this, is all 6 six digits have to entered, which means you will need to enter leading zeros. The number of digits can also be easily changed.
OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...