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

Recommended Answers

All 8 Replies

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.

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?

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.

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 :)

1

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

Hi all....

I have received feedback for my algorithm and apparently it's not what my tutor was looking for he's asking for steps at the beginning of the algorithm to show how I got the data from the user, and steps at the end outputting the relevant values.

I am confused about this and don't know what he actually want,thought that the algorithm I wrote was pretty neat.

I would like to ask for help from you guys here...really appreciate it.

did u mean a user input?

if so, u can ask user how many books they want 1st.use box to get user input.
User can choose whether individual,library or school also by using user input box.then only continue with your flow chart

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.