google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Java program that simulates strategies to increase sales for a business with additional features and functionality

Sunday, March 30, 2025

Java program that simulates strategies to increase sales for a business with additional features and functionality

 Here's an updated version of the program with additional features and functionality:


Sales Booster Program (Updated)


import java.util.Scanner;

import java.util.ArrayList;


// Define a class for products

class Product {

    String name;

    double price;

    int quantity;


    public Product(String name, double price, int quantity) {

        this.name = name;

        this.price = price;

        this.quantity = quantity;

    }

}


// Define a class for customers

class Customer {

    String name;

    String contact;

    int purchaseCount;


    public Customer(String name, String contact) {

        this.name = name;

        this.contact = contact;

        this.purchaseCount = 0;

    }

}


// Define a class for sales strategies

class SalesStrategy {

    // Strategy 1: Discounted Pricing

    public void applyDiscount(Product product, double discountPercentage) {

        double discountedPrice = product.price - (product.price * discountPercentage / 100);

        System.out.println("Discounted price for " + product.name + ": $" + discountedPrice);

    }


    // Strategy 2: Bundle Deals

    public void offerBundleDeal(Product product1, Product product2, double bundleDiscountPercentage) {

        double totalBundlePrice = product1.price + product2.price;

        double bundleDiscount = totalBundlePrice * bundleDiscountPercentage / 100;

        double finalBundlePrice = totalBundlePrice - bundleDiscount;

        System.out.println("Bundle deal for " + product1.name + " and " + product2.name + ": $" + finalBundlePrice);

    }


    // Strategy 3: Loyalty Rewards

    public void rewardLoyalCustomers(Customer customer, double rewardPercentage) {

        double rewardAmount = customer.purchaseCount * rewardPercentage;

        System.out.println("Reward amount for loyal customer " + customer.name + ": $" + rewardAmount);

    }

}


// Define a class for sales management

class SalesManagement {

    ArrayList<Product> products;

    ArrayList<Customer> customers;

    SalesStrategy salesStrategy;


    public SalesManagement() {

        this.products = new ArrayList<>();

        this.customers = new ArrayList<>();

        this.salesStrategy = new SalesStrategy();

    }


    public void addProduct(Product product) {

        products.add(product);

    }


    public void addCustomer(Customer customer) {

        customers.add(customer);

    }


    public void displayProducts() {

        System.out.println("Products:");

        for (Product product : products) {

            System.out.println(product.name + ": $" + product.price);

        }

    }


    public void displayCustomers() {

        System.out.println("Customers:");

        for (Customer customer : customers) {

            System.out.println(customer.name + ": " + customer.contact);

        }

    }


    public void applySalesStrategy() {

        Scanner scanner = new Scanner(System.in);

        System.out.println("Choose a sales strategy:");

        System.out.println("1. Discounted Pricing");

        System.out.println("2. Bundle Deals");

        System.out.println("3. Loyalty Rewards");

        int choice = scanner.nextInt();


        switch (choice) {

            case 1:

                System.out.println("Enter product name:");

                String productName = scanner.next();

                Product product = getProduct(productName);

                if (product != null) {

                    System.out.println("Enter discount percentage:");

                    double discountPercentage = scanner.nextDouble();

                    salesStrategy.applyDiscount(product, discountPercentage);

                } else {

                    System.out.println("Product not found!");

                }

                break;

            case 2:

                System.out.println("Enter product 1 name:");

                String product1Name = scanner.next();

                Product product1 = getProduct(product1Name);

                System.out.println("Enter product 2 name:");

                String product2Name = scanner.next();

                Product product2 = getProduct(product2Name);

                if (product1 != null && product2 != null) {

                    System.out.println("Enter bundle discount percentage:");

                    double bundleDiscountPercentage = scanner.nextDouble();

                    salesStrategy.offerBundleDeal(product1, product2, bundleDiscountPercentage);

                } else {

                    System.out.println("One or both products not found!");

                }

                break;

            case 3:

                System.out.println("Enter customer name:");

                String customerName = scanner.next();

                Customer customer = getCustomer(customerName);

                if (customer != null) {

                    System.out.println("Enter reward percentage:");

                    double rewardPercentage = scanner.nextDouble();

                    salesStrategy.rewardLoyalCustomers(customer, rewardPercentage);

                } else {

                    System.out.println("Customer not found!");

                }

                break;

            default:

                System.out.println("Invalid choice!");

        }

    }


    private Product getProduct(String productName) {

        for (Product product : products) {

            if (product.name.equals(productName)) {

                return product;

            }

        }

        return null;

    }


    private Customer getCustomer(String customerName) {

        for (Customer customer : customers) {

            if (customer.name.equals(customerName)) {

                return customer;

            }

        }

        return null;

    }

}


public class SalesBooster {

    public static void main(String[] args) {

        SalesManagement salesManagement = new SalesManagement();


        // Add products

        salesManagement.addProduct(new Product("Product A", 100.0, 10));

        salesManagement.addProduct(new Product("Product B", 200.0, 5));


        // Add customers

        salesManagement.addCustomer(new Customer("John Doe", "123-456-7890"));

        salesManagement.addCustomer(new Customer("Jane Doe", "987-654-3210"));


        Scanner scanner = new Scanner(System.in);

        while (true) {

            System.out.println("Sales Booster Program");

            System.out.println("1. Display Products");

            System.out.println("2. Display Customers");

            System.out.println("3. Apply Sales Strategy");

            System.out.println("4. Exit");

            System.out.print("Enter your choice: ");

            int choice = scanner.nextInt();


            switch (choice) {

                case 1:

                    salesManagement.displayProducts();

                    break;

                case 2:

                    salesManagement.displayCustomers();

                    break;

                case 3:

                    salesManagement.applySalesStrategy();

                    break;

                case 4:

                    System.out.println("Exiting...");

                    return;

                default:

                    System.out.println("Invalid choice!");

            }

        }

    }

}



This updated program includes the following additional features:


1. *Product and customer management*: The program allows you to add and display products and customers.

2. *Sales strategy application*: The program enables you to apply different sales strategies, such as discounted pricing, bundle deals, and loyalty rewards.

3. *User-friendly interface*: The program features a menu-driven interface that makes it easy to navigate and use.


Note that this program is still a simplified example and does not cover real-world complexities like:


- Inventory management

- Order processing and fulfillment

- Payment processing and invoicing

- Customer relationship management


To make this program more comprehensive and useful, you would need to consider these factors and add additional features and functionality.

No comments:

Post a Comment

The rotation of money in business

 The rotation of money in business refers to the flow of funds within a company, encompassing various financial activities and transactions....