Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A local supermarket chain has recently started offering discounts to its customers based on their purchase history. They want to implement a loyalty program where

A local supermarket chain has recently started offering discounts to its customers based on their purchase history. They want to implement a loyalty program where customers can accumulate points for every purchase they make and redeem those points for discounts on their future purchases.

To implement this loyalty program, the supermarket chain needs to keep track of the customers' points and the discounts they are eligible for. They have decided to use Java's TreeMap data structure to store this information because of its ability to sort keys in ascending order and efficient search and retrieval of elements.

As a student, your task is to implement a Java program that uses TreeMap to store customer loyalty points and discounts. The program should allow the supermarket staff to perform the following tasks:

Add a new customer to the loyalty program with an initial point balance of zero.

Increment the point balance of an existing customer by a specified amount.

Check the point balance of a customer.

Calculate the discount amount a customer is eligible for based on their accumulated points.

Implementation:

Create a class named Customer to represent a customer and include the following fields: name, email, and points.

Create a class named LoyaltyProgram to manage the customer data using TreeMap.

Implement the following methods in the LoyaltyProgram class:

addCustomer(Customer customer): Adds a new customer to the loyalty program.

addPoints(String email, int points): Increments the point balance of an existing customer.

getPoints(String email): Returns the point balance of a customer.

getDiscount(String email): Returns the discount amount a customer is eligible for based on their accumulated points.

Implement a user-friendly command-line interface to interact with the LoyaltyProgram class.

Write unit tests to verify the correct functionality of the LoyaltyProgram class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

What is an employee assistance program?

Answered: 1 week ago

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago