Help with Algorithm please!

Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
Thread Solved

Join Date: Dec 2008
Posts: 8
Reputation: Nepenthe is an unknown quantity at this point 
Solved Threads: 0
Nepenthe Nepenthe is offline Offline
Newbie Poster

Help with Algorithm please!

 
0
  #1
Oct 25th, 2009
Hi,

I have this task that I need to solve and am stuck.I would like some help on this please.I am fairly new to this,so not sure what I should do.....really appreciated if anyone could help me out

Question
Write an Algorithm to calculate discounts.


Bookstore is offering discounts to customers. Classifications of customers are:
Library,Schools,Educational institutions
no of books purchased
more than 50 books receive 30% discount
25 to 49 20%"
15 to 24 books 15%
5 to 14 books 10%
less than 5 books 5%

If customer is an Individual:
more than 25 books 25% discount
5 to 24 books 15% discount

Thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 466
Reputation: Grn Xtrm will become famous soon enough Grn Xtrm will become famous soon enough 
Solved Threads: 39
Grn Xtrm's Avatar
Grn Xtrm Grn Xtrm is offline Offline
Posting Pro in Training
 
0
  #2
Oct 25th, 2009
You can use a series of if statements to test the input of the number of books. Depending on the input, the different if statements execute. Each statement will produce a different discount.
Check out my new band URL on facebook. I'm the bass player. :) Become a fan and leave comments if you like.
URL on facebook!
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: Nepenthe is an unknown quantity at this point 
Solved Threads: 0
Nepenthe Nepenthe is offline Offline
Newbie Poster
 
0
  #3
Oct 25th, 2009
Originally Posted by Grn Xtrm View Post
You can use a series of if statements to test the input of the number of books. Depending on the input, the different if statements execute. Each statement will produce a different discount.


Oke, by that do you mean IF ELSE statement?
So would that be something like this:
if purchase =(30+ books then
finalPrice = price / 100 x 10

But what am confused about is that there's no price given for the books. So I assume that I will have to work out the discount only from the amount of books bought is this right?
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,620
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 205
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso
 
0
  #4
Oct 25th, 2009
Yes, that's right. And you're going to have to get input from the user asking if they are an institution or individual and how many books they want to buy.
Out.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: Nepenthe is an unknown quantity at this point 
Solved Threads: 0
Nepenthe Nepenthe is offline Offline
Newbie Poster
 
0
  #5
Oct 26th, 2009
Originally Posted by BestJewSinceJC View Post
Yes, that's right. And you're going to have to get input from the user asking if they are an institution or individual and how many books they want to buy.

Thank you
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 9
Reputation: Nepenthe8 is an unknown quantity at this point 
Solved Threads: 0
Nepenthe8's Avatar
Nepenthe8 Nepenthe8 is offline Offline
Newbie Poster
 
0
  #6
15 Days Ago
1
Last edited by Nepenthe8; 15 Days Ago at 9:02 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: Nepenthe is an unknown quantity at this point 
Solved Threads: 0
Nepenthe Nepenthe is offline Offline
Newbie Poster
 
0
  #7
15 Days Ago
Originally Posted by BestJewSinceJC View Post
Yes, that's right. And you're going to have to get input from the user asking if they are an institution or individual and how many books they want to buy.

Hi,

Okay this is what I got so far and would like to know if am on the right track.
If CustomerType = "Library" Or CustomerType = "School" Or CustomerType = "educational institution" Then

If Qty >= 50 Then
Discount = 30

ElseIf Qty >= 25 And Qty <= 49 Then
Discount = 20

ElseIf Qty >= 15 And Qty <= 24 Then

Discount = 15

ElseIf Qty >= 5 And Qty <= 14 Then

Discount = 10

ElseIf Qty < 5 And Qty > 0 Then

Discount = 5

Else: Discount = 0

If CustomerType = "Individual" Then

If Qty >= 25 Then

Discount = 25

ElseIf Qty <= 24 And Qty >= 5 Then

Discount = 15

Else: Discount = 0

If CustomerType = " " Then

Discount = 0




Also, I just figured out that I need to draw a diagram or flowchart supporting the Psuedo Code. I have attached what I have as a draft but am really stuck on it and confused on how to draw this flowchart with the given scenario.

Help is much appreciated.

Thanks
Attached Files
File Type: doc flowchart.doc (25.5 KB, 1 views)
Reply With Quote Quick reply to this message  
Reply

Tags
algorithm

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Computer Science Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC