943,761 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 3752
  • C# RSS
Nov 7th, 2005
0

Price Calculations

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
barry t is offline Offline
10 posts
since Mar 2005
Nov 7th, 2005
0

Re: Price Calculations

Quote originally posted by barry t ...
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

Quote ...

$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
Team Colleague
Reputation Points: 84
Solved Threads: 99
<Insert title here>
tayspen is offline Offline
1,542 posts
since Jul 2005
Nov 7th, 2005
0

Re: Price Calculations

yes when the dollar value is under $16.50 the deduction is - 24% - 32cents = net value
Reputation Points: 10
Solved Threads: 0
Newbie Poster
barry t is offline Offline
10 posts
since Mar 2005
Nov 8th, 2005
1

Re: Price Calculations

I'm assuming you meant 22.00 OR Great and 16.50 OR Greater
C# Syntax (Toggle Plain Text)
  1. double valueAfterDeduction(double oldValue){
  2. if(oldValue >= 22.00) oldValue -= 3.3;
  3. else if(oldValue >= 16.5) oldValue = (oldValue * .85) - 1.81;
  4. else oldValue = (oldValue * .76) - .32;
  5. return oldValue;
  6. }
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Nov 8th, 2005
0

Re: Price Calculations

thankyou campkev I will try your code thankyou for your help barry t
Reputation Points: 10
Solved Threads: 0
Newbie Poster
barry t is offline Offline
10 posts
since Mar 2005
Nov 10th, 2005
0

Re: Price Calculations

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");
Reputation Points: 10
Solved Threads: 0
Newbie Poster
barry t is offline Offline
10 posts
since Mar 2005
Nov 10th, 2005
0

Re: Price Calculations

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.


C# Syntax (Toggle Plain Text)
  1. double Price, Rate, Amount, Deductions, NetPrice;
  2.  
  3. Price = double.Parse(txtPrice.Text);
  4. Rate = double.Parse(txtRate.Text);
  5. Deductions = double.Parse(txtDeductions.Text);
  6.  
  7. if(Price >= 22.00) Price = Price - 3.30);
  8. else if(Price >= 16.5)Price = (Price * .85)-1.81;
  9. else Price = (Price * .76)-.32;
  10.  
  11.  
  12. //txtAmount.Text = Amount.ToString("C"); commented this line out because I don't know what you want here.
  13. txtNetPrice.Text = Price.ToString("C");
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: C# PDA programming
Next Thread in C# Forum Timeline: Printing text to printer; PosPrinter class information





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC