954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Price Calculations

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

barry t
Newbie Poster
10 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 
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

tayspen
<Insert title here>
Team Colleague
1,622 posts since Jul 2005
Reputation Points: 84
Solved Threads: 99
 

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

barry t
Newbie Poster
10 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

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;
}
campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

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

barry t
Newbie Poster
10 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

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");

barry t
Newbie Poster
10 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

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");
campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You