0% found this document useful (0 votes)
22 views16 pages

Online Shopping Cart in Java Project

The document is a mini project report on an 'Online Shopping Cart in Java using Classes and Objects', developed by students of Global Academy of Technology for their Bachelor's degree in Electronics and Communication Engineering. It outlines the project's objectives, implementation details, and results, emphasizing the use of object-oriented programming principles to create a user-friendly console application for purchasing fruits. The report also discusses the advantages, applications, and educational value of the project, highlighting its potential for further development into more complex systems.

Uploaded by

hussainzanath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views16 pages

Online Shopping Cart in Java Project

The document is a mini project report on an 'Online Shopping Cart in Java using Classes and Objects', developed by students of Global Academy of Technology for their Bachelor's degree in Electronics and Communication Engineering. It outlines the project's objectives, implementation details, and results, emphasizing the use of object-oriented programming principles to create a user-friendly console application for purchasing fruits. The report also discusses the advantages, applications, and educational value of the project, highlighting its potential for further development into more complex systems.

Uploaded by

hussainzanath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

“Jnana Sangama”, Belagavi, Karnataka, INDIA

MINI PROJECT(22ECE55A)
A Report
On
“ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJECTS”
Submitted in the partial fulfillment for the award of Bachelor Degree in Electronics and
Communication Engineering

Submitted by

ARPITHA C 1GA22EC016
SUHASINI S M 1GA22EC163
SHRUSTI K N 1GA22EC415

Under the Guidance of


KRUTHIK CHAND D C
Assistant Professor, Dept. of ECE, GAT

Department of Electronics and Communication Engineering


GLOBAL ACADEMY OF TECHNOLOGY
(Autonomous Institute, Affiliated to VTU, Belagavi)
Rajarajeshwarinagar, Bengaluru - 560 098
2024 –OF
GLOBAL ACADEMY 2025TECHNOLOGY
(Autonomous Institute, Affiliated to VTU, Belagavi)
Rajarajeshwarinagar, Bengaluru - 560 098
Department of Electronics and Communication Engineering

CERTIFICATE
Certified that the Mini Project (22ECE55A) entitled
“ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJECTS”
Carried out by,
ARPITHA C 1GA22EC016
SUHASINI S M 1GA22EC163
SHRUSTI K N 1GA22EC415

Bonafide students of Global Academy of Technology in partial fulfillment for the award of
Bachelor of Engineering in Electronics and Communication Engineering of the Visveswaraya
Technological University, Belagavi during the academic year 2024-25. It is certified that all
corrections/suggestions indicated for Internal Assessment have been incorporated in the Report
deposited in the Departmental library. The Mini Project report has been approved as it satisfies the
academic requirements in respect of Mini Project work prescribed for the said Degree.

Signature of the guide Signature of the HOD Signature of the Principal

Kruthik Chand D C Dr. Madhavi Mallam Dr. Balakrishna H B


Assistant Professor, ECE HOD, ECE Principal
Global Academy of Technology Global Academy of Technology Global Academy of Technology
ACKNOWLEDGEMENT

The satisfaction and euphoria that accompany the successful completion of any task would be
incomplete without the mention of the people who made it possible, whose constant guidance
and encouragement crowned the efforts with success.

We would like to thank Management of Global Academy of Technology for providing such a
healthy environment for the successful completion of Seminar work.

We would like to express our thanks to the Principal Dr. Balakrishna H B for their
encouragement that motivated us for the successful completion of Seminar work.

Also, we would like to express our deepest sense of gratitude to Dr. Madhavi Mallam, Head
of Department for her constant support and guidance throughout the Seminar work.

We would also like to thank the project guide KRUTHIK CHAND D C, Assistant Professor,
Department of Electronics and Communication Engineering and all other teaching and non-
teaching staff of Electronics and Communication Engineering Department who has directly or
indirectly helped us in the completion of Seminar work.

Last, but not the least, we would hereby acknowledge and thank our Parents who have been a
source of inspiration and also instrumental in the successful completion of the project work.

ARPITHA C 1GA22EC016
SUHASINI S M 1GA22EC163
SHRUSTI K N 1GA22EC415
TABLE OF CONTENTS

1. Introduction…………………………………………………………...….1
2. Code Overview…………………………………………………………...3
3. Results…………………………………………………………………....7
4. Advantages and applications……………………………………………..9
5. Conclusions……………………………………………………………...11
ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJECTS

ABSTRACT

This mini project titled "Online Shopping Cart using Classes and Objects" is a console-based
application developed in Java to simulate a basic e-commerce experience focused on
purchasing fruits. The system utilizes object-oriented programming (OOP) principles to
structure the functionality through classes and objects, ensuring modularity, reusability, and
clarity.

Upon launching the program, users are presented with a predefined list of fruits along with
their respective prices. Users can select a desired fruit, input the quantity required, and the
system dynamically calculates the total cost based on the selection. The shopping process is
designed to be interactive, offering three primary options after each transaction:

1. Continue Shopping – to add more fruits to the cart,

2. View Bill – to display a detailed summary of selected items with their individual and
total costs,

3. Exit – to terminate the session.

The core functionality is implemented through dedicated classes for managing the inventory,
handling user selections, computing totals, and generating the bill. This project serves as a
practical introduction to object-oriented concepts and user interaction within a shopping
context, making it suitable for beginners learning Java and OOP.

DEPT. Of ECE, GAT


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

INTRODUCTION

With the rapid growth of e-commerce and online retail platforms, shopping carts have become
an essential component of the digital buying experience. This mini project, titled "Online
Shopping Cart in Java using Classes and Objects," is a simple yet effective simulation of a
basic shopping cart system, specifically designed for educational purposes. The main objective
is to provide a hands-on understanding of how object-oriented programming (OOP) concepts
can be applied to solve real-world problems using Java.

This project focuses on the purchase of fruits through a user-friendly, menu-driven console
application. It showcases how everyday tasks like selecting items, computing prices, and
generating a final bill can be automated using code. The key elements of this application
revolve around the use of classes and objects, which help in organizing data and behaviour into
logical units.

The system starts by displaying a list of available fruits along with their respective prices. Users
can interact with the system by selecting fruits of their choice and specifying the quantity they
wish to purchase. Each selection is added to a virtual cart, and the total price is calculated
accordingly. After each transaction, users are given a set of three choices:

• Continue Shopping to add more items to the cart,

• View Bill to display a summary of all purchases made so far,

• Exit to end the session.

The project is structured into multiple classes, such as:

• Fruit : to store the name and price of each fruit,

• CartItem : to represent each item selected by the user including quantity and cost,

• ShoppingCart : to manage the list of items, perform total calculations, and display the
bill.

This modular structure allows for clear separation of responsibilities, easier debugging, and
potential future expansion—such as adding categories, implementing discounts, or integrating
payment simulations.

DEPT. Of ECE, GAT Page 1


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJECTS

In summary, this project not only demonstrates the fundamentals of OOP but also mimics the
core workflow of real-world shopping applications. It serves as a solid foundation for students
and beginners to grasp the principles of object-oriented design and apply them in building
interactive, user-centric programs.

DEPT. Of ECE, GAT Page 2


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJECTS

CODE OVERVIEW

import [Link];
import [Link];
public class Main {
int quantity =0;
int code =0;
String name ;
String price;
ArrayList<String> list = new ArrayList<String>();
Static Scanner sc = new Scanner([Link]);
static int amount = 0;
static int total =0;

public static void main(String[] args) {


Main obj = new Main();
[Link]("*********************");
[Link](" MART ");
[Link]("*********************");
[Link]();
int choice = [Link]();
switch(choice){
case 1:while(choice == 1){
[Link]();
[Link]();
total = total + amount;
[Link]();
int choice2 = [Link]();
if(choice2 == 2){
[Link]();

DEPT. Of ECE, GAT Page 3


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

break;
}
}
break;
case 2:[Link]("Exit Shopping") ;
break;
default:[Link](“Invalid Input”);
break;
}
}

public void showCart(){


[Link]("*********************");
[Link](" Enter your choice!!");
[Link]("1. Display fruits");
[Link]("2. Exit");
[Link]("*********************");
}
public void fruits(){
[Link]("*********************");
[Link]("Displaying fruits");
[Link]("Sl no. Fruit Price");
[Link](" 1 . Apple 200/Kg");
[Link](" 2 . Mango 100/Kg");
[Link](" 3 . Orange 50/Kg");
[Link]("*********************");
}

public void shopping(){


[Link]("*********************");

DEPT. Of ECE, GAT Page 4


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

[Link](" Enter your choice!!");


[Link]("1. Continue Shopping");
[Link]("2. View Bill");
[Link]("3. Exit");
[Link]("*********************");
}

public void selection(){


[Link]("Enter your choice of fruit!!");
int fruitChoice = [Link]();
if(fruitChoice == 1){
code=1;
name="Apple";
price="200/Kg";
[Link]("Apple selected");
[Link]("Enter quantity");
quantity = [Link]();
amount = quantity * 200;
}
else if(fruitChoice == 2){
code=2;
name="Mango";
price="100/Kg";
[Link]("Mango selected");
[Link]("Enter quantity");
quantity = [Link]();
amount = quantity * 100;
}
else if(fruitChoice == 3){
code=3;

DEPT. Of ECE, GAT Page 5


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

name="Orange";
price="50/Kg";
[Link]("Orange selected");
[Link]("Enter quantity");
quantity = [Link]();
amount = quantity * 50;
}
[Link](" " +code+ " " + name+ " " + price +" " +quantity + " "
+amount);
}

public void bill(){


[Link]("*********************");
[Link](" Bill ");
[Link]("*********************");
[Link]("Sl no. Fruit Price Quantity Amount");
for(String s : list){
[Link](s);
}
[Link]("*********************");
[Link](" "+"TOTAL:"+" "+ total +" ");
[Link](" Thanks for Shopping!!! ");
[Link]("*********************");
}

DEPT. Of ECE, GAT Page 6


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

RESULTS

The Online Shopping Cart mini project was successfully developed and executed using the
principles of Object-Oriented Programming in Python. The system met all its functional
requirements by providing an interactive and user-friendly interface for selecting fruits,
entering quantities, and calculating the total bill.

DEPT. Of ECE, GAT Page 7


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

DEPT. Of
DEPT. Of ECE,
ECE, GAT
GAT Page 86
ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

ADVANTAGES

➢ Modularity with Classes & Objects

• Code is easier to manage and debug. For example, Fruit, Cart, and User can be separate
classes.

➢ Reusability

• Once the class structure is built, it can be reused or extended for other types of items
like vegetables or snacks.

➢ Scalability

• You can easily add more features like discounts, payment gateways, or delivery options
without disturbing the existing codebase.

➢ User-Friendly Interaction

• With options like "Continue Shopping", "View Bill", and "Exit", users get a smooth and
intuitive shopping experience.

➢ Real-World Simulation

• Object-oriented design closely mimics how real shopping works—items (fruits) have
properties (name, price), and actions (select, view bill) are modeled as methods.

APPLICATIONS

➢ Educational Projects
• Ideal for students learning Java and OOP principles through practical implementation.

➢ E-Commerce Prototypes

• A stepping stone for developing more complex online shopping platforms.

➢ Inventory Management Simulators

DEPT. Of ECE, GAT Page 9


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

• Can be extended to track stock, expiry dates, or supply chains for small grocery
vendors.

➢ CLI-Based Retail Tools

• Useful for small shops that use command-line tools for billing and checkout in remote
or low-tech environments.

DEPT. Of ECE, GAT Page 10


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

CONCLUSION

The development of an online fruit shopping cart system using Java and object-oriented
programming (OOP) principles serves as an excellent example of how real-world scenarios can
be effectively translated into software solutions. This project highlights the importance of
modular design and abstraction, where each component of the system is clearly defined and
encapsulated within classes and objects.

By defining a Fruit class to represent individual items with attributes such as name and price,
and implementing a Cart class to manage user selections and total cost calculations, the
program emphasizes the key benefits of OOP—reusability, maintainability, and scalability. The
separation of concerns allows each class to handle specific responsibilities, making the system
easier to debug, update, and extend. For example, new fruit types or features like discounts or
taxes can be added with minimal changes to the existing structure.

The interactive user flow, which provides choices such as "Continue Shopping", "View Bill",
and "Exit", ensures a user-friendly experience that closely mimics real-world shopping
behavior. The logical structure of the menu-driven interface improves user engagement and
simplifies navigation through the shopping process.

From an educational standpoint, this project reinforces fundamental Java concepts such as class
creation, object instantiation, method calling, collection handling (e.g., using lists to store
fruits), and control structures. It offers hands-on experience in building a functional console-
based application and demonstrates how to apply theoretical programming knowledge to solve
practical problems.

Furthermore, the simplicity and clarity of the system make it an ideal base for further
development. It can be expanded into a full-fledged GUI application, connected to databases
for persistent storage, or integrated with web technologies to create a complete e-commerce
platform.

In conclusion, this project successfully showcases how object-oriented programming can be


utilized to design and implement an efficient, intuitive, and expandable online shopping cart
system. It not only serves as a useful tool for managing virtual purchases but also provides
valuable insights into structured programming, logical design, and software engineering
practices.

DEPT. Of ECE, GAT Page11


Page 9

Common questions

Powered by AI

The project highlights the importance of modular design and separation of concerns in software engineering by effectively structuring the shopping cart application into discrete modules or classes, each responsible for a specific part of the system. This design approach allows for clear delineation of functionality—such as defining classes for item representation, cart management, and user interaction—that results in more organized, maintainable, and scalable code . By encapsulating specific responsibilities within distinct classes, the system enhances ease of debugging, updating, and extending its functionality, as changes can be localized to particular modules without affecting others. This modular design is crucial in real-world applications where software complexity and requirements are continually evolving .

The project's design suggests several potential future expansions to improve its functionality. Given its modular structure, features such as implementing discounts, adding new product categories, or simulating payment processes can be integrated easily . Development of a graphical user interface (GUI) could enhance user interaction and widen its applicability beyond text-based environments . Integration with cloud-based databases could allow for persistent data storage, multi-user access, and real-time inventory management. Expansions could also include advanced analytics to track shopping trends or personalized marketing features that tailor the shopping experience based on user behavior .

The project demonstrates the effective application of OOP concepts in translating real-world scenarios into software solutions by employing modular design through classes and objects. Each class encapsulates specific data and functions reflective of real shopping cart components, such as fruits as objects with attributes and methods to manage their selection and billing . By designing the system to manage user interactions through object-oriented structures, the project mimics actual shopping processes—like selecting items and calculating totals—enhancing the realism and utility of the software . This abstraction of real-world problems into discrete programming units not only brings clarity and order to the system design but also allows for scalability and maintainability, crucial aspects in software development .

The interaction flow of the online shopping cart project contributes to a user-friendly experience by offering a straightforward, menu-driven interface that provides users with clear options such as "Continue Shopping", "View Bill", and "Exit" after each transaction . This logical structure ensures simplicity in navigation and enhances user engagement, making the system intuitive and more closely aligned with real-world shopping behaviors . Such an approach not only simplifies the transaction process but also improves the overall interaction by giving users the ability to make decisions easily according to their shopping needs.

The shopping cart system can be extended to become a more comprehensive e-commerce platform by implementing various features and integrations. First, features like customer accounts, discounts, taxes, and payment gateways can be added to diversify functionality . Integration with databases could provide persistent storage for inventory, user data, and transaction history, enhancing data management and accessibility. Developing a graphical user interface (GUI) would improve usability and broaden user appeal beyond command-line interactions . Furthermore, expanding the system to support multiple categories and inventory management could evolve it from a simple fruit shopping simulation to a full-scale e-commerce application capable of tracking stock quantities, managing supply chains, and providing delivery logistics .

The report highlights several benefits of using object-oriented programming (OOP) principles in the design of an online shopping cart application. Firstly, OOP ensures modularity, as the functionality is structured through classes and objects which compartmentalize data and behavior. This makes code easier to manage and debug, as seen with separate classes for Fruit, CartItem, and ShoppingCart . Secondly, it promotes reusability, enabling the existing class structures to be easily extended for additional features or items like vegetables or snacks . Thirdly, it offers scalability, allowing for new features such as discounts, payment gateways, or delivery options to be added without disrupting the existing codebase . Lastly, OOP closely mimics real-world scenarios, which simplifies user interaction by organizing tasks into logical units .

The logical menu-driven interface enhances the user's shopping experience in the shopping cart system by providing a straightforward and intuitive navigation path through the shopping process. Users are given clear options such as "Continue Shopping", "View Bill", and "Exit", which align closely with typical user goals during an online shopping session . This structured approach reduces potential user confusion and helps maintain user engagement by simplifying decision-making at each step. The menu-driven interface effectively emulates real-world shopping experiences in a console environment, thereby improving user satisfaction and system usability .

The online shopping cart project offers several educational advantages for students learning Java and OOP principles. It serves as a practical introduction to object-oriented concepts like class creation, object instantiation, method calls, and handling collections . By simulating a real-world e-commerce scenario, it provides a context-rich environment where students can apply theoretical knowledge to solve practical programming problems . The project's simplicity and clarity also make it an ideal base for further exploration and development, allowing students to incrementally add complexity like GUI elements or database integration, thereby reinforcing learning through hands-on experience .

The project is suitable for use as a prototype for more complex online shopping platforms due to its modular and scalable design. The use of object-oriented programming (OOP) facilitates easy extension by allowing additional features like different categories of products, payment gateway integration, and promotions to be added without requiring significant structural changes . Its separation of responsibilities—such as distinct classes for inventory management and user transactions—ensures that new components can be integrated with minimal impact on existing functionality . Moreover, the interactive, console-driven user interface serves as a strong foundational model for developing more sophisticated graphical user interfaces, making it an ideal starting point for students or developers looking to expand upon an e-commerce system .

In the shopping cart system project, the classes are designed to encapsulate specific functionalities and data, showcasing the effectiveness of OOP principles. The Fruit class is used to store the name and price of each fruit, serving as a basic data structure for the items being sold . The CartItem class represents each item selected by the user, including its quantity and total cost, capturing user-specific order details . Finally, the ShoppingCart class manages the list of items, performs total cost calculations, and facilitates the generation and display of the bill, acting as the core component for transaction management and bill generation . This modular design enables clear separation of responsibilities and supports scalability, as new features can be integrated with minimal changes.

You might also like