0% found this document useful (0 votes)
4 views8 pages

Java Project 4.0

The document outlines a Java program for a shopping bill generation system for a grocery store called 'Metro Mart.' It allows users to input product details, calculates totals, applies discounts and taxes, and generates a formatted invoice. Key programming concepts used include Object-Oriented Programming, collections, user input handling, and date formatting.

Uploaded by

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

Java Project 4.0

The document outlines a Java program for a shopping bill generation system for a grocery store called 'Metro Mart.' It allows users to input product details, calculates totals, applies discounts and taxes, and generates a formatted invoice. Key programming concepts used include Object-Oriented Programming, collections, user input handling, and date formatting.

Uploaded by

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

Project: Shopping Bill Generation System

Abstract
This Java program implements a basic shopping bill generation system for a grocery store
named "Metro Mart." The system allows users to input product details such as ID, name,
quantity, and price. The program calculates the total price for each product, adds all product
totals to calculate an overall price, applies a discount, calculates taxes (SGST and CGST),

JAVA MINI
and then generates a formatted invoice with all these details.

Concepts of JAVA used:


The Java program implements several key programming concepts:

1. Object-Oriented Programming (OOP): The Product class encapsulates product


details, demonstrating encapsulation and object creation.

PROJECT
2. Constructors: The Product class includes a constructor for initializing product
attributes.
3. Encapsulation: Private fields in the Product class are accessed via public getter
methods.
4. Collections: An is used to store and manage multiple Product objects.
5. Loops: A do-while loop allows the user to input multiple products until they choose to
stop.
6. User Input: The Scanner class is used to read user input from the console.
7. String Formatting: The program uses String. format and System. out. format to align
the output in a tabular format.
8. Date and Time: The Simple Date Format and Calendar classes are used to display the
current date and time.
9. Arithmetic Operations: Calculations for total price, discount, SGST, and CGST
demonstrate basic arithmetic operations.
10. Conditional Statements: The program uses conditional checks to continue adding
products based on user input.
The key functions of the program are:

1. Product Class Methods: Includes a constructor to initialize product details, better


methods to access private fields, and display methods to format and print product
information.
2. User Input and Product Addition: Uses a do-while loop and Scanner to gather
product details from the user and add them to an Array List of Product objects.
3. Invoice Generation: Formats and prints an invoice with product details, totals,
discounts, and taxes using string formatting and arithmetic operations.
4. Date and Time Display: Utilizes Simple Date Format and Calendar to display the
current date and day of the week on the invoice.
5. Overall Calculation: Computes the overall price, discount, SGST, CGST, and final
amount to be paid, displaying these calculations in the formatted invoice output.

TEAM MEMBESRS

JAVA MINI
Project team members
[Link] Student Sign
Name USN

01 Pradeep. T 2KA22IS035

02 Amogh. V 2KA22IS003

PROJECT
03 Nagaraj. D 2KA22IS030

04 Kirankumar. B 2KA22IS018
Guide Sigmature:

import [Link];

import [Link];

import [Link];

JAVA MINI
import [Link];

import [Link];

import [Link];

class Product

PROJECT
// properties

private String id;

private String pname;

private int qty;

private double price;

private double totalPrice;

// constructor

Product(String id, String pname, int qty, double price, double totalPrice)

[Link]=id;

[Link] = pname;

[Link] = qty;

[Link] = price;

[Link] = totalPrice;
}

// getter methods

public String getId()

return id;

public String getPname()

return pname;

public int getQty()

JAVA MINI
{

return qty;

public double getPrice()

PROJECT
return price;

public double getTotalPrice()

return totalPrice;

//displayFormat

public static void displayFormat()

[Link]("-----------------------------------------------------------------------------------------------------------
------------------------");

[Link]("\nProduct ID \t\tName\t\tQuantity\t\tRate \t\t\t\tTotal Price\n");

[Link]("-----------------------------------------------------------------------------------------------------------
------------------------\n");
}

// display

public void display()

[Link](" %-9s %-9s %5d %9.2f %14.2f\n" ,id,


pname, qty, price, totalPrice);

public class ShoppingBill

public static void main(String args[])

JAVA MINI
{

// variables

String id = null;

String productName = null;

int quantity = 0;

PROJECT
double price = 0.0;

double totalPrice = 0.0;

double overAllPrice = 0.0;

double cgst, sgst, subtotal=0.0, discount=0.0;

char choice = '\0';

[Link]("\t\t\t\t--------------------Invoice-----------------");

[Link]("\t\t\t\t\t "+" "+"Metro Mart Grocery Shop");

[Link]("\t\t\t\t\t3/98 Mecrobertganj New Mumbai");

[Link]("\t\t\t\t\t" +" " +"Opposite Metro Walk");

[Link]("GSTIN: 03AWBPP8756K592"+"\t\t\t\t\t\t\tContact: (+91)


9988776655");

//format of date and time

SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

Date date = new Date();

Calendar calendar = [Link]();


String[] days = new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday" };

//prints current date and time

[Link]("Date: "+[Link](date)+"
"+days[[Link](Calendar.DAY_OF_WEEK) - 1]+"\t\t\t\t\t\t (+91) 9998887770");

Scanner scan = new Scanner([Link]);

[Link]("Enter Customer Name: ");

String customername=[Link]();

//create Scanner class object

//creating an ArrayList to store the product

List<Product> product = new ArrayList<Product>();

do

JAVA MINI
{

// read input values

[Link]("Enter the product details: ");

[Link]("Product ID: ");

id = [Link]();

PROJECT
[Link]("Product Name: ");

productName = [Link]();

[Link]("Quantity: ");

quantity = [Link]();

[Link]("Price (per unit): ");

price = [Link]();

//calculate total price for a particular product

totalPrice = price * quantity;

//calculates overall price

overAllPrice = overAllPrice + totalPrice;

//creates Product class object and add it to the List

[Link]( new Product(id, productName, quantity, price, totalPrice) );

// ask for continue shopping?

[Link]("Want to add more items? (y or n): ");

//reads a character Y or N
choice = [Link]().charAt(0);

//read remaining characters, don't store (no use)

[Link]();

while (choice == 'y' || choice == 'Y');

//display all product with its properties

[Link]();

for (Product p : product)

[Link]();

JAVA MINI
//price calculation

[Link]("\n\t\t\t\t\t\t\t\t\t\tTotal Amount (Rs.) " +overAllPrice);

//calculating discount

discount = overAllPrice*2/100;

[Link]("\n\t\t\t\t\t\t\t\t\t\t Discount (Rs.) " +discount);

PROJECT
//total amount after discount

subtotal = overAllPrice-discount;

[Link]("\n\t\t\t\t\t\t\t\t\t\t Subtotal "+subtotal);

//calculating tax

sgst=overAllPrice*12/100;

[Link]("\n\t\t\t\t\t\t\t\t\t\t SGST (%) "+sgst);

cgst=overAllPrice*12/100;

[Link]("\n\t\t\t\t\t\t\t\t\t\t CGST (%) "+cgst);

//calculating amount to be paid by buyer

[Link]("\n\t\t\t\t\t\t\t\t\t\t Invoice Total " +(subtotal+cgst+sgst));

[Link]("\t\t\t\t----------------Thank You for Shopping!!-----------------");

[Link]("\t\t\t\t Visit Again");

// close Scanner

[Link]();

}
}

JAVA MINI
PROJECT

You might also like