Report JavaOSC
Report JavaOSC
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
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.
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.
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.
CODE OVERVIEW
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
int quantity =0;
int code =0;
String name ;
String price;
ArrayList<String> list = new ArrayList<String>();
Static Scanner sc = new Scanner(System.in);
static int amount = 0;
static int total =0;
break;
}
}
break;
case 2:System.out.println("Exit Shopping") ;
break;
default:System.out.println(“Invalid Input”);
break;
}
}
name="Orange";
price="50/Kg";
System.out.println("Orange selected");
System.out.println("Enter quantity");
quantity = sc.nextInt();
amount = quantity * 50;
}
list.add(" " +code+ " " + name+ " " + price +" " +quantity + " "
+amount);
}
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.
ADVANTAGES
➢ 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.
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.