Serendipity Booksellers has a book club that awards points to its customers base
ID: 3850555 • Letter: S
Question
Serendipity Booksellers has a book club that awards points to its customers based on the number of books purchased each month. The points are awarded as follows: If a customer purchases 0 books, he or she earns 0 points. If a customer purchases 1 book, he or she earns 5 points. If a customer purchases 2 books, he or she earns 15 points. If a customer purchases 3 books, he or she earns 30 points. If a customer purchases 4 or more books, he or she earns 60 points. Write a pseudocode algorithm that asks the user to enter the number of books that he or she has purchased this month and then displays the number of points awarded. Problem analysis is not required.Explanation / Answer
Problem : Design an algorithm to display the points awarded based on the number of books purchased a month.
Algorithm:
Step 1: START
Step 2: Declare two integer variables no_of_books and awarded_points
Step 3: Ask user to enter number of books he/she purchased and store it in the variable no_of_books.
Step 4: Assign the variable awarded_points value as per the no_of_books as follows:
If no_of_books = 0
Then set awarded_points = 0
Else If no_of_books = 1
Then set awarded_points = 5
Else If no_of_books = 2
Then set awarded_points = 15
Else If no_of_books = 3
Then set awarded_points = 30
Else set awarded_points = 60
End If
Step 5: Display awarded_points.
Step 6: STOP
Description:
Above is the pseudo code required for this question.
As per the pseudo code writing, you should first write the problem statement, then you should write the approach to solve it.
So, the steps for the solutions are as follows:
First declare two variables: one to take input from user and one to display the result.
Take the user input in one variable. This is the number of books he/she purchased in that month.
Then check the number of books value using the nested-if statements.
If he/she has not bought any book, he won't earn any point.
If he/she had purchased 1 book, assign 5 points.
Similarly write the conditions as per the question.
Now, as this step is completed, the value is stored in awarded_points variable.
So in the next step, display its value.
As the desired task is finished, stop the process now.
So this is the description for the same algorithm.
Do comment if there is any query, Thank you. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.