0% found this document useful (0 votes)
3 views

Report JavaOSC

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
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Report JavaOSC

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
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

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 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;

public static void main(String[] args) {


Main obj = new Main();
System.out.println("*********************");
System.out.println(" MART ");
System.out.println("*********************");
obj.showCart();
int choice = sc.nextInt();
switch(choice){
case 1:while(choice == 1){
obj.fruits();
obj.selection();
total = total + amount;
obj.shopping();
int choice2 = sc.nextInt();
if(choice2 == 2){
obj.bill();

DEPT. Of ECE, GAT Page 2


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

break;
}
}
break;
case 2:System.out.println("Exit Shopping") ;
break;
default:System.out.println(“Invalid Input”);
break;
}
}

public void showCart(){


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

public void shopping(){


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

DEPT. Of ECE, GAT Page 3


ONLINE SHOPPING CART IN JAVA USING CLASSES AND OBJETCS

System.out.println(" Enter your choice!!");


System.out.println("1. Continue Shopping");
System.out.println("2. View Bill");
System.out.println("3. Exit");
System.out.println("*********************");
}

public void selection(){


System.out.println("Enter your choice of fruit!!");
int fruitChoice = sc.nextInt();
if(fruitChoice == 1){
code=1;
name="Apple";
price="200/Kg";
System.out.println("Apple selected");
System.out.println("Enter quantity");
quantity = sc.nextInt();
amount = quantity * 200;
}
else if(fruitChoice == 2){
code=2;
name="Mango";
price="100/Kg";
System.out.println("Mango selected");
System.out.println("Enter quantity");
quantity = sc.nextInt();
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";
System.out.println("Orange selected");
System.out.println("Enter quantity");
quantity = sc.nextInt();
amount = quantity * 50;
}
list.add(" " +code+ " " + name+ " " + price +" " +quantity + " "
+amount);
}

public void bill(){


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

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

You might also like