Tools Advisor | Other Tools

Sustainable Discount Calculator

Application to calculate discounts based on customer spending ranges. Provides accurate discount amount and percentage for better customer experience.


Empty image or helper icon

Prompt

The discount method implemented in Q.2.2 is not sustainable. Mr. Gucci has
decided to rather offer the following discounts on a long‐term basis.
Amount Spend Percentage Discount
0 – R1000 10%
R1001 – R3000 30%
R3001 or more 35%
  
Write the pseudocode snippet that will represent the section of Mr. Gucci’s
application that allows a cashier at the shop to determine the amount of discount
to be awarded to a customer based on the total amount payable by the customer.
The cashier will enter the amount payable and then the discount will be calculated
and displayed. You also need to display the percentage discount awarded. NB: You
need to make use of parallel arrays as part of your answe.

Answer

Problem Analysis

  • Mr. Gucci wants to implement a sustainable discount method based on the amount spent by customers.
  • The discounts are defined based on different spending ranges: 10% for 0 to R1000, 30% for R1001 to R3000, and 35% for R3001 or more.
  • The application needs to calculate and display the discount amount and percentage based on the amount payable by the customer.
  • Parallel arrays will be used to store the spending ranges and corresponding percentage discounts.

Strategic Solution Development

  1. Define two parallel arrays: spendRanges to store the spending ranges and discountPercentages to store the corresponding discount percentages.
  2. Implement a function in the application that takes the amount payable as input and calculates the discount based on the spending ranges defined.
  3. Loop through the spendRanges array to determine the appropriate discount percentage based on the amount payable.
  4. Calculate the discount amount using the determined percentage.
  5. Display the calculated discount amount and the corresponding percentage to the cashier.

Code-Based Solutions (Pseudocode)

The following pseudocode snippet represents the described logic:

// Define parallel arrays for spending ranges and corresponding discount percentages
spendRanges = [0, 1000, 3000]
discountPercentages = [10, 30, 35]

function calculateDiscount(amountPayable):
    discount = 0
    discountPercentage = 0
    
    // Determine the discount percentage based on the amount payable
    for i from 0 to length(spendRanges) - 1:
        if amountPayable <= spendRanges[i]:
            discountPercentage = discountPercentages[i]
            break
    
    // Calculate the discount amount
    discount = (amountPayable * discountPercentage) / 100
    
    // Display the discount amount and percentage
    display "Discount amount: " + discount
    display "Discount percentage: " + discountPercentage

// Prompt the cashier to enter the amount payable
input amountPayable
calculateDiscount(amountPayable)

Detailed Explanation

  • In this pseudocode snippet, spendRanges and discountPercentages arrays are defined to store the spending ranges and corresponding discount percentages.
  • The calculateDiscount function calculates the discount amount and percentage based on the amount payable by the customer.
  • It iterates through the spendRanges array to find the right discount percentage based on the amount payable entered by the cashier.
  • The discount amount is calculated using the determined discount percentage and displayed along with the percentage to the cashier.

By implementing this pseudocode snippet, Mr. Gucci's application can efficiently determine the discount to be awarded to customers based on their total amount payable, ensuring a sustainable discount method.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

Application to calculate discounts based on customer spending ranges. Provides accurate discount amount and percentage for better customer experience.