Hi I am trying to write an app for price calculations what i need to do is make cut off points for different dollar values the values are when a product is over $22.00 the deduction $3.30. When a product is over $16.50 and under $22.00 the deduction is dollar value -15%-$1.81 and when the product is under $16.50 the deduction is dollar value -24%-.32cents.I am new to code writing and need help thankyou barry t

Recommended Answers

All 6 Replies

Hi I am trying to write an app for price calculations what i need to do is make cut off points for different dollar values the values are when a product is over $22.00 the deduction $3.30. When a product is over $16.50 and under $22.00 the deduction is dollar value -15%-$1.81 and when the product is under $16.50 the deduction is dollar value -24%-.32cents.I am new to code writing and need help thankyou barry t


$16.50 the deduction is dollar value -24%-.32cents.I am new to code writing and need help thankyou barry t

So wait is that saying when the price in under/over the value you subtract 24% the subract .32 cents for that #?

-T

BTW welcome to daniweb

yes when the dollar value is under $16.50 the deduction is - 24% - 32cents = net value

I'm assuming you meant 22.00 OR Great and 16.50 OR Greater

double valueAfterDeduction(double oldValue){
if(oldValue >= 22.00) oldValue -= 3.3;
else if(oldValue >= 16.5) oldValue =  (oldValue * .85) - 1.81;
else oldValue = (oldValue * .76) - .32;
return oldValue;
}

thankyou campkev I will try your code thankyou for your help barry t

double Price, Rate, Amount, Deductions, NetPrice;

Price = double.Parse(txtPrice.Text);
Rate = double.Parse(txtRate.Text);
Deductions = double.Parse(txtDeductions.Text);

Amount = (Price >= 22.00 - 3.30);
if(Price >= 16.5)Price = (Price * .85)-1.81;
else Price = (Price * .76)-.32;
NetPrice = Price - Amount - Deductions;

txtAmount.Text = Amount.ToString("C");
txtNetPrice.Text = NetPrice.ToString("C");

ok, now I am completely confused. What are you trying to do? What is the Amount variable supposed to represent? What is the rate? You read that in but never use it. And is the user supposed to set his own deductions? I thought that was set.

Anyway, based on your original question and this code i would do the following, but, to be honest, I'm not really sure what you want.

double Price, Rate, Amount, Deductions, NetPrice;

Price = double.Parse(txtPrice.Text);
Rate = double.Parse(txtRate.Text);
Deductions = double.Parse(txtDeductions.Text);

if(Price >= 22.00) Price = Price - 3.30);
else if(Price >= 16.5)Price = (Price * .85)-1.81;
else Price = (Price * .76)-.32;


//txtAmount.Text = Amount.ToString("C"); commented this line out because I don't know what you want here.
txtNetPrice.Text = Price.ToString("C");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.