0% found this document useful (0 votes)
25 views14 pages

Java Online Shopping Cart Project

The document presents a mini project report on an 'Online Shopping Cart in Java using Classes and Objects,' developed by students of Global Academy of Technology as part of their Bachelor Degree in Electronics and Communication Engineering. The project simulates a basic e-commerce experience for purchasing fruits, utilizing object-oriented programming principles to ensure modularity and user interaction. It includes an overview of the code, results, advantages, applications, and concludes with insights into the importance of OOP in software development.

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)
25 views14 pages

Java Online Shopping Cart Project

The document presents a mini project report on an 'Online Shopping Cart in Java using Classes and Objects,' developed by students of Global Academy of Technology as part of their Bachelor Degree in Electronics and Communication Engineering. The project simulates a basic e-commerce experience for purchasing fruits, utilizing object-oriented programming principles to ensure modularity and user interaction. It includes an overview of the code, results, advantages, applications, and concludes with insights into the importance of OOP in software development.

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
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 (22ECE56) 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 Global Academy of Technology Global Academy of Technology
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…………………………………………………………....2
3. Results………………………………………………………………….....6
4. Advantages and applications……………………………………………...8
5. Conclusions…………………………………………………………….....9
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 OBJECTS

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.
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 1


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 2


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 3


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 4


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 5


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 6


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

DEPT. Of ECE, GAT Page 7


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


• 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 8


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 Page 9

Common questions

Powered by AI

The key principles of object-oriented programming (OOP) utilized in the Online Shopping Cart project include modularity, reusability, scalability, and abstraction. Modularity is achieved by structuring the code into multiple classes, such as Fruit, CartItem, and ShoppingCart, allowing each class to handle specific responsibilities, making the code easier to manage and debug . Reusability is demonstrated by the classes that can be reused or extended to other types of items like vegetables or snacks . Scalability is enhanced by the project’s ability to easily incorporate additional features, such as discounts, without disturbing the existing codebase . Finally, abstraction is applied through class encapsulation, allowing for clear separation of data and functionality .

The project design facilitates the extension of features through its modular class structure and adherence to object-oriented principles. Each class manages distinct responsibilities, such as representing fruit details or managing cart items, allowing the system to be extended without major alterations to the existing code. For example, new classes could be added for additional item categories, discounts, or payment options with minimal disruption . The separation of concerns means new features, like tax calculations or graphical interfaces, can be integrated by expanding on current classes or adding new ones, leveraging the inherent scalability and reusability of the design .

Classes and objects play a crucial role in ensuring the system's modularity and reusability in the Online Shopping Cart project by encapsulating related data and behaviors into single logical entities. This encapsulation leads to a well-organized code structure where each class, such as Fruit or CartItem, represents specific data attributes and actions, thereby providing clear boundaries of responsibility . Modularity is achieved as these classes work independently yet cohesively, which facilitates maintenance and debugging . Furthermore, reusability is ensured because once defined, these classes can be easily extended or reused within the project or in other applications without significant alterations, thus enhancing flexibility and efficiency in code management and future project undertakings .

The project's implementation highlights the importance of abstraction by demonstrating how complex user interactions can be broken down into simpler, manageable parts through class encapsulation. Each class in the system—such as Fruit, CartItem, and ShoppingCart—represents specific data and functionality, such as storing item details or managing cart operations, abstracting the underlying complexity from the user and other parts of the program . This abstraction allows developers to focus on individual aspects of the system without worrying about the entire codebase, thus enabling clearer logic, easier maintenance, and extensibility. Abstraction ensures that system modifications or expansions have minimal impact on the overall system .

The Online Shopping Cart project simulates a real-world e-commerce experience by offering a menu-driven console application that mimics how users select items, compute prices, and view bills. Users are presented with a list of fruits and their prices, can select a desired fruit, input the required quantity, and the system calculates the total cost. It also allows users to continue shopping, view their bill, or exit the session, which aligns with typical online shopping workflows . Additionally, the use of object-oriented design closely resembles how items with properties (e.g., fruits with names and prices) and actions (e.g., selection, billing) are modeled in real applications .

The project manages user interaction and navigation through a menu-driven console interface that guides users through the shopping process. After launching, it presents users with options to display available fruits and their prices. Users can select fruits, specify quantities, and add items to the virtual cart. The system provides interactive options after each transaction, such as "Continue Shopping", "View Bill", and "Exit", enabling intuitive navigation and engagement. The menu-driven design simplifies user interaction while simulating a typical shopping flow, allowing users to review their purchases or terminate the session .

The Online Shopping Cart project offers several educational benefits for students learning Java and object-oriented programming (OOP). It provides practical exposure to OOP concepts like class creation, object instantiation, method calling, and collection handling through a functional console-based application . The project demonstrates the application of theoretical programming knowledge to solve real-world problems by simulating a shopping environment . It reinforces Java fundamentals by requiring students to implement modular code, fostering skills in software design, debugging, and scalability . The simplicity and clarity of the project also make it an ideal starting point for further development, encouraging exploratory learning and system enhancement .

The Online Shopping Cart project serves as a prototype for more complex e-commerce applications by demonstrating key aspects such as product selection, pricing, transaction processing, and user interaction. The modular structure of the project with distinct classes for items and cart management offers a scalable foundation for initiating more sophisticated systems . It showcases essential components like item catalogs and billing functionality, which can be further developed into GUI applications with database connectivity and enhanced features like payment processing and inventory tracking . The project's adherence to object-oriented principles allows for easy integration of advanced functionalities such as user authentication, order history, and personalized recommendations, which are common in full-scale e-commerce platforms .

The main advantages of using a modular design in the Online Shopping Cart project include ease of management, debugging, scalability, and reusability. The separation of functionalities into distinct classes allows specific responsibilities to be isolated, making the code more manageable and easier to debug. This design supports scalability, as new features can be added without significant changes to the existing codebase, such as introducing new item categories or payment gateways . Reusability is also enhanced, as the well-defined class structures can be easily expanded or adapted for different types of items or scenarios, facilitating the extension of the existing application .

The Online Shopping Cart project effectively meets its goal of educating Java beginners in object-oriented programming (OOP) concepts by providing a hands-on, practical approach to learning. It introduces foundational OOP principles such as encapsulation, inheritance, and polymorphism through concrete examples of class interactions and method implementations. The project allows beginners to experience the full cycle of software development, from designing class structures for specific functionalities to implementing user interactions and managing system data . By simplifying real-world scenarios into a console application, it reinforces theoretical learning with practical experience, offering a comprehensive understanding of both Java syntax and OOP methodologies. The modular design ensures learners can focus on individual aspects of the project, promoting exploration and deeper understanding of complex concepts . Moreover, the project's potential for expansion encourages creativity and critical thinking, essential skills in software engineering .

You might also like