Laundry Management System in CSharp

Laundry Management System

Introduction

In the fast-paced world we live in, managing day-to-day tasks efficiently is crucial. From mundane chores to complex operations, technology plays a vital role in simplifying our lives. In this blog post, we will explore a practical example of how C# console application can be leveraged to create a Laundry Management System. This project encompasses user authentication, customer information handling, service display, and even a simulated payment process.

About the System

Laundry management is an essential aspect of our daily routines, and streamlining the process can save time and effort. The Laundry Management System developed in C# console application provides a user-friendly interface to handle various tasks related to customer information and laundry services.

Flow of the System

  1. Login using if else statement, display welcome message
  2. Select option to execute using switch statement
    1. 1 – for customer info
    2. 2 for Services offered
  3. If 1 then the system will ask to input the name, contact and address of the customer
  4. Select option to execute:
  • 1 for customer info
  • 2 for Services offered

If 1 then the system will ask to input the name, contact and address

If 2 then the system will list the services offered with prices

  1. The system will ask the user to input the service choice, amount or number of dress then the system will compute the total amount
  2. The system will then compute the total amount and the payment process will happen.

Example Source code

using System;

class Program
{
static void Main()
{
string username = "admin";
string password = "password";

Console.WriteLine("Laundry Management System");
Console.WriteLine("------------------------");

// Login
Console.Write("Enter username: ");
string enteredUsername = Console.ReadLine();
Console.Write("Enter password: ");
string enteredPassword = Console.ReadLine();

if (enteredUsername == username && enteredPassword == password)
{
Console.WriteLine("Welcome, {0}!", username);

// Display menu
Console.WriteLine("\nSelect an option:");
Console.WriteLine("1 - Customer Info");
Console.WriteLine("2 - Services Offered");
Console.WriteLine("0 - Exit");

// Get user input
Console.Write("Enter option: ");
string input = Console.ReadLine();

// Validate input
if (int.TryParse(input, out int option))
{
if (option == 1)
{
CustomerInfo();
}
else if (option == 2)
{
DisplayServices();

// Additional steps for service choice and payment
ProcessLaundryService();
}
else if (option == 0)
{
Console.WriteLine("Exiting the program. Goodbye!");
}
else
{
Console.WriteLine("Invalid option. Please try again.");
}
}
else
{
Console.WriteLine("Invalid input. Please enter a valid option.");
}
}
else
{
Console.WriteLine("Invalid username or password. Exiting program.");
}
}

static void CustomerInfo()
{
Console.WriteLine("\nEnter customer details:");

Console.Write("Name: ");
string name = Console.ReadLine();

Console.Write("Contact: ");
string contact = Console.ReadLine();

Console.Write("Address: ");
string address = Console.ReadLine();

Console.WriteLine("\nCustomer Information:");
Console.WriteLine("Name: {0}", name);
Console.WriteLine("Contact: {0}", contact);
Console.WriteLine("Address: {0}", address);
}

static void DisplayServices()
{
Console.WriteLine("\nServices Offered:");

// You can add more services and their prices as needed
Console.WriteLine("1. Regular Wash - $5.00");
Console.WriteLine("2. Dry Cleaning - $8.00");
Console.WriteLine("3. Express Service - $10.00");
// Add more services as needed
}

static void ProcessLaundryService()
{
Console.Write("\nEnter the service choice (1, 2, 3): ");
if (int.TryParse(Console.ReadLine(), out int serviceChoice))
{
Console.Write("Enter the number of dresses: ");
if (int.TryParse(Console.ReadLine(), out int numberOfDresses))
{
double totalAmount = CalculateTotalAmount(serviceChoice, numberOfDresses);

Console.WriteLine("\nTotal Amount: ${0}", totalAmount);

// Simulate payment process
Console.Write("Enter payment amount: $");
if (double.TryParse(Console.ReadLine(), out double paymentAmount) && paymentAmount >= totalAmount)
{
Console.WriteLine("Payment successful. Thank you!");
}
else
{
Console.WriteLine("Invalid payment amount. Payment failed.");
}
}
else
{
Console.WriteLine("Invalid input for the number of dresses. Please enter a valid number.");
}
}
else
{
Console.WriteLine("Invalid input for the service choice. Please enter a valid number.");
}
Console.ReadKey();
}

static double CalculateTotalAmount(int serviceChoice, int numberOfDresses)
{
// Prices for different services
double[] servicePrices = { 5.00, 8.00, 10.00 };

if (serviceChoice >= 1 && serviceChoice <= servicePrices.Length)
{
double servicePrice = servicePrices[serviceChoice - 1];
return servicePrice * numberOfDresses;
}
else
{
Console.WriteLine("Invalid service choice. Unable to calculate total amount.");
return 0;
}
Console.ReadKey();
}
}

Explanation

Login Section:

Security is paramount, even in a console application. The project begins with a simple yet effective user authentication mechanism. Users are required to input a username and password, providing a secure gateway to the laundry management system. This ensures that only authorized personnel can access and operate the system.

string username = "admin";
string password = "password";

Console.WriteLine("Laundry Management System");
Console.WriteLine("------------------------");

// Login
Console.Write("Enter username: ");
string enteredUsername = Console.ReadLine();
Console.Write("Enter password: ");
string enteredPassword = Console.ReadLine();

if (enteredUsername == username && enteredPassword == password)
  • The program starts by defining a username and password.
  • The user is prompted to enter a username and password.
  • If the entered credentials match the predefined ones, the program proceeds; otherwise, it exits.

Main Menu Section:

The project adopts a menu-driven interface to enhance user experience. Once authenticated, users are presented with a menu displaying options such as managing customer information, exploring laundry services, and exiting the system. The intuitive design ensures that users can easily navigate through the application.

Console.WriteLine("Welcome, {0}!", username);

// Display menu
Console.WriteLine("\nSelect an option:");
Console.WriteLine("1 - Customer Info");
Console.WriteLine("2 - Services Offered");
Console.WriteLine("0 - Exit");

// Get user input
Console.Write("Enter option: ");
string input = Console.ReadLine();

// Validate input
if (int.TryParse(input, out int option))
  • Displays a welcome message and the main menu with options.
  • Prompts the user to enter an option.
  • Validates whether the entered input is a valid integer.

Option Handling:

if (option == 1)
{
CustomerInfo();
}
else if (option == 2)
{
DisplayServices();

// Additional steps for service choice and payment
ProcessLaundryService();
}
else if (option == 0)
{
Console.WriteLine("Exiting the program. Goodbye!");
}
else
{
Console.WriteLine("Invalid option. Please try again.");
}
  • If the user chooses option 1, it calls the CustomerInfo method to gather and display customer details.
  • If the user chooses option 2, it calls the DisplayServices method to show available services and then calls ProcessLaundryService to handle service choice and payment.
  • If the user chooses option 0, it exits the program.
  • If the user enters an invalid option, an error message is displayed.

Customer Information and Services Display:

The system enables the input and retrieval of customer information. Users can seamlessly enter customer details, including name, contact information, and address. The system then organizes and displays this information, providing a comprehensive overview of the clientele.

One of the key functionalities of the Laundry Management System is the ability to display available laundry services. Users are presented with a menu showcasing different services, each with its associated price. This feature ensures transparency and helps customers make informed choices.

static void CustomerInfo()
{
Console.WriteLine("\nEnter customer details:");

Console.Write("Name: ");
string name = Console.ReadLine();

Console.Write("Contact: ");
string contact = Console.ReadLine();

Console.Write("Address: ");
string address = Console.ReadLine();

Console.WriteLine("\nCustomer Information:");
Console.WriteLine("Name: {0}", name);
Console.WriteLine("Contact: {0}", contact);
Console.WriteLine("Address: {0}", address);
}

static void DisplayServices()
{
Console.WriteLine("\nServices Offered:");

// You can add more services and their prices as needed
Console.WriteLine("1. Regular Wash - $5.00");
Console.WriteLine("2. Dry Cleaning - $8.00");
Console.WriteLine("3. Express Service - $10.00");
// Add more services as needed
}
  • CustomerInfo() collects and displays customer details.
  • DisplayServices() shows a list of available services and their prices.

Laundry Service Processing:

The project goes beyond mere information display by incorporating a streamlined process for handling laundry services. Users can input their service choice and the number of dresses they wish to launder. The system, in turn, computes the total amount based on the selected service and quantity.

Simulated Payment Process:

To mirror real-world scenarios, the application simulates a payment process. Users are prompted to enter the payment amount, and the system validates the payment. This step ensures that the Laundry Management System not only assists in service selection but also provides a seamless transaction experience.

static void ProcessLaundryService()
{
Console.Write("\nEnter the service choice (1, 2, 3): ");
if (int.TryParse(Console.ReadLine(), out int serviceChoice))
{
Console.Write("Enter the number of dresses: ");
if (int.TryParse(Console.ReadLine(), out int numberOfDresses))
{
double totalAmount = CalculateTotalAmount(serviceChoice, numberOfDresses);

Console.WriteLine("\nTotal Amount: ${0}", totalAmount);

// Simulate payment process
Console.Write("Enter payment amount: $");
if (double.TryParse(Console.ReadLine(), out double paymentAmount) && paymentAmount >= totalAmount)
{
Console.WriteLine("Payment successful. Thank you!");
}
else
{
Console.WriteLine("Invalid payment amount. Payment failed.");
}
}
else
{
Console.WriteLine("Invalid input for the number of dresses. Please enter a valid number.");
}
}
else
{
Console.WriteLine("Invalid input for the service choice. Please enter a valid number.");
}
Console.ReadKey();
}

static double CalculateTotalAmount(int serviceChoice, int numberOfDresses)
{
// Prices for different services
double[] servicePrices = { 5.00, 8.00, 10.00 };

if (serviceChoice >= 1 && serviceChoice <= servicePrices.Length)
{
double servicePrice = servicePrices[serviceChoice - 1];
return servicePrice * numberOfDresses;
}
else
{
Console.WriteLine("Invalid service choice. Unable to calculate total amount.");
return 0;
}
Console.ReadKey();
}
  • ProcessLaundryService() handles the service choice, number of dresses input, calculates the total amount, and simulates a payment process.
  • CalculateTotalAmount() calculates the total amount based on the selected service and the number of dresses.

FREE DOWNLOAD PDF TUTORIAL

FREE DOWNLOAD SOURCE CODE

Conclusion

In conclusion, this C# console application exemplifies the power and versatility of the programming language in creating practical solutions. The Laundry Management System, with its user-friendly interface and efficient functionalities, showcases how technology can simplify everyday tasks. This project serves as a foundation for further enhancements and customization, demonstrating the adaptability of C# in meeting specific requirements.

Stay tuned for the next parts of this blog series where we delve deeper into the code, exploring individual components and understanding how each contributes to the overall functionality of the Laundry Management System.

Related Topics and Articles:

Course Outline in C#

You may visit our Facebook page for more information, inquiries, and comments. Please subscribe also to our YouTube Channel to receive free capstone projects resources and computer programming tutorials.

Hire our team to do the project.

, , , , , , , , , ,

Post navigation