0% found this document useful (0 votes)
10 views10 pages

Java Shopping Cart Application Guide

The document is a project report for a Shopping Cart Application developed in Java as part of a Bachelor of Technology degree. It outlines the application's objectives, key features, and the concepts used, including Object-Oriented Programming principles. The report includes pseudo code and actual Java code for the application's functionality, demonstrating how users can add, remove, view items, and calculate the total amount in a shopping cart.

Uploaded by

sereneesapphiree
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)
10 views10 pages

Java Shopping Cart Application Guide

The document is a project report for a Shopping Cart Application developed in Java as part of a Bachelor of Technology degree. It outlines the application's objectives, key features, and the concepts used, including Object-Oriented Programming principles. The report includes pseudo code and actual Java code for the application's functionality, demonstrating how users can add, remove, view items, and calculate the total amount in a shopping cart.

Uploaded by

sereneesapphiree
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

A Project Report on

Shopping Cart Application


submitted in partial fulfillment for award of the degree of Bachelor of Technology in

Department of computer science

by

[Link] 24321A0568
[Link] 24321A0570
Prachi Dixit 24321A0573
[Link] 24321A0576
[Link] 24321A0578

Under the esteemed Guidance of

AMTUL SHANAZ

Assistant Professor, Department of CSE

Bhoj Reddy Engineering College for Women

Department of Computer science

(Sponsored by Sangam Laxmibai Vidyapeet, approved by AICTE & affiliated O JNTUH)

Vinaynagar, IS Sadan Crossroads, Hyderabad - 500 059

Ph: +91-40-2453 7282; Website: [Link]; Email:


principal@[Link]

2024-2025

1
Department of CSE, BRECW
Introduction
The Shopping Cart Application is a simple Java-based console program designed to simulate
the functionalities of an online shopping system. It allows users to add items, remove items,
display items in the cart, and calculate the final bill amount. This project helps beginners
understand Java programming concepts such as classes, objects, arrays/lists, user input
handling, and menu-driven logic. It demonstrates how basic shopping systems work in a
simplified way and serves as a beginner-friendly Java project.

� Objectives

- To understand and implement Object-Oriented Programming (OOP) concepts.

- To create a menu-driven Java application.

- To use classes, objects, and methods effectively.

- To add, remove, and display items in the cart.

- To calculate the total bill based on price and quantity.

- To provide a clean and simple shopping cart simulation.

⚙ Key Features

- Add items to the cart.

- Remove items by name.

- View all items in the cart.

- Display the total amount.

- Predefined product list option.

- Simple console-based interface.

2
Department of CSE, BRECW
� Concepts Used

- Classes and Objects

- Constructors

- Encapsulation

- ArrayList

- Arrays

- Methods

- Loops and Conditional Statements

- Scanner (User Input)

Pseudo Code
START

Create Item class with name, price, quantity

Create Cart class with list of items and methods

addItem(), removeItem(), viewCart(), getTotalAmount()

In Main:

LOOP until user selects Exit

Display menu

Read user choice

IF choice == Add Item:

Ask for name, price, quantity

Add item to cart

ELSE IF choice == Remove Item:

Ask for item name

3
Department of CSE, BRECW
Remove from cart

ELSE IF choice == View Cart:

Display all items

ELSE IF choice == Total Amount:

Calculate and display total

ELSE IF choice == Exit:

End Program

END

FLOWCHART

4
Department of CSE, BRECW
CODE
Java Code ([Link])
public class Item {
private String name;
private double price;
private int quantity;

public Item(String name, double price, int quantity) {


[Link] = name;
[Link] = price;
[Link] = quantity;
}

public double getTotalPrice() {


return price * quantity;
}

public String getName() { return name; }


public double getPrice() { return price; }
public int getQuantity() { return quantity; }

@Override
public String toString() {
return name + " | Price: " + price + " | Qty: " + quantity + " | Total: " + getTotalPrice();
}
}

Java Code ([Link])


import [Link];

public class Cart {

5
Department of CSE, BRECW
private ArrayList<Item> items = new ArrayList<>();

public void addItem(Item item) {


[Link](item);
}

public void removeItem(String name) {


[Link](i -> [Link]().equalsIgnoreCase(name));
}

public void viewCart() {


if ([Link]()) {
[Link]("Cart is empty.");
return;
}
for (Item item : items) {
[Link](item);
}
}

public double getTotalAmount() {


double total = 0;
for (Item i : items) {
total += [Link]();
}
return total;
}
}

6
Department of CSE, BRECW
Java Code ([Link])
import [Link];

public class Main {


public static void main(String[] args) {
Cart cart = new Cart();
Scanner sc = new Scanner([Link]);

while (true) {
[Link]("\n---- Shopping Cart Menu ----");
[Link]("1. Add Item");
[Link]("2. Remove Item");
[Link]("3. View Cart");
[Link]("4. Total Amount");
[Link]("5. Exit");
[Link]("Enter choice: ");

int choice = [Link]();


[Link]();

switch (choice) {
case 1:
[Link]("Enter item name: ");
String name = [Link]();
[Link]("Enter price: ");
double price = [Link]();
[Link]("Enter quantity: ");
int qty = [Link]();
[Link](new Item(name, price, qty));
[Link]("Item added!");

7
Department of CSE, BRECW
break;

case 2:
[Link]("Enter item name to remove: ");
String removeName = [Link]();
[Link](removeName);
[Link]("Item removed!");
break;

case 3:
[Link]("\nItems in Cart:");
[Link]();
break;

case 4:
[Link]("Total Amount: " + [Link]());
break;

case 5:
[Link]("Thank you for shopping!");
[Link](0);

default:
[Link]("Invalid choice!");
}
}
}
}

8
Department of CSE, BRECW
OUTPUT

9
Department of CSE, BRECW
10
Department of CSE, BRECW

You might also like