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

Java language microproject pdf-1

Uploaded by

Cricket Lover
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Java language microproject pdf-1

Uploaded by

Cricket Lover
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Micro ProjectReport

Online Shopping

1.0Aims/Benefits of the Micro-Project:

To learn/understand the concepts of the java programming and apply at


the places required. The main aim of this micro project is to understand
the java code login designed for performing online shopping.

2.0 Rationale:

The basic application for online shopping i.e. in that user can creates his/her
account. Using this application user can shop anything what they want.

3.0 Course Outcomes Addressed:

1. Develop Java program using Object Oriented Methodology.


2.Understand inheritance in Java programming.
3. Implement Exception Handling.
4. Develop program for handling I/O and file streams.
5. Develop program using Multithreading.
3.0 Proposed Methodology:
After choosing the topic for our micro project, we decided to collect some
information
Related to our project topic and do some research on it.Based on that info.
We would be developing some logic for carrying out different various functions
related to online shopping.

4.0 Action Plan:

Sr.no Details of Activity Planned Planned Name of responsible


start date finish team member.
date
1 Topic discussion &Selection
2 Review of literature 1.Vaidip Dipak Nikam
3 Aim/benefits & importance 2. Pavan sunil Baviskar
3. Nikita Vitthal Bedse
4 Resource required
4. Janhavi Pravin Kakuste
5 Analysis of collected data
6 Design of system
7 Coding &testing of modules
8 Compilation of presentation
9 Presentation of seminar
10 Final submission

5.0 Name of Team Members with Roll no:

Roll No Name of team member


202 Vaidip Dipak Nikam
212 Pavan Sunil Baviskar
213 Nikita Vitthal Bedse
232 Janhavi Pravin Kakuste
6.0 Output of Micro-Project:

 Program code-

import java.util.*;
class ShopDetails
{
private String accno;
private String name;
private long balance;
Scanner sc = new Scanner(System.in);

String id = null;
String productName = null;
int quantity = 0;
double price = 0.0;
double totalPrice = 0.0;
double overAllPrice = 0.0;
double subtotal=0.0, discount=0.0;
char choice = '\0';

ShopDetails()
{

ShopDetails(String id, String pname, int qty, double price, double


totalPrice)
{
this.id=id;
this.productName = pname;
this.quantity = qty;
this.price = price;
this.totalPrice = totalPrice;
}
//method to open new account
public void openAccount()
{
System.out.print("Enter Account No: ");
accno = sc.next();
System.out.print("Enter Name: ");
name = sc.next();
System.out.print("Enter Card Balance: ");
balance = sc.nextLong();

System.out.println("__________________________________________
___________");

}
public void showAccount()
{
System.out.println("Name of account holder: " + name);
System.out.println("Account no.: " + accno);
System.out.println("Balance: " + balance);

System.out.println("__________________________________________
__________");

}
//To add balance to shoppie card

public void deposit()


{
long amt;
System.out.println("Enter the amount you want to deposit: ");
amt = sc.nextLong();
balance = balance + amt;

}
//displayFormat
public static void displayFormat()
{

System.out.format("__________________________________________
__________________________________________________________
______________");
System.out.print("\nProduct ID \t Name \t\t Quantity \t\tRate \t\t\t\t
TotalPrice \n");

System.out.format("__________________________________________
__________________________________________________________
______________\n");
}

// display
public void display()
{
System.out.format(" %-9s %-9s %5d %9.2f " ,id,
productName, quantity, price, totalPrice);
}

public void shopping()


{
List<ShopDetails> product = new ArrayList<ShopDetails>();

do
{
// read input values
System.out.println("Enter the product details: ");

System.out.print("Product ID: ");


id = sc.nextLine();

System.out.print("Product Name: ");


productName = sc.nextLine();

System.out.print("Quantity: ");
quantity = sc.nextInt();

System.out.print("Price (per unit): ");


price = sc.nextDouble();

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


product.add(new ShopDetails(id, productName, quantity,
price,totalPrice) );

// ask for continue shopping?

System.out.print("Want to add more items? (y or n): ");


//reads a character Y or N

choice = sc.next().charAt(0);
//read remaining characters, don't store (no use)
sc.nextLine();
}
while
(choice == 'y' || choice == 'Y');
//display all product with its properties
ShopDetails.displayFormat();
for(ShopDetails p : product)
{
p.display();
}
//price calculation
System.out.println("\n\t\t\t\t\t\t\t\t\t\tTotal Amount (Rs.) "
+overAllPrice);

//calculating discount
discount = overAllPrice*2/100;
System.out.println("\n\t\t\t\t\t\t\t\t\t\t Discount (Rs.) " +discount);
//total amount after discount

subtotal = overAllPrice-discount;
System.out.println("\n\t\t\t\t\t\t\t\t\t\t Subtotal "+subtotal);

//calculating amount to be paid by buyer


System.out.println("\n\t\t\t\t\t\t\t\t\t\t Invoice Total " +(subtotal));
System.out.println("\t\t\t\t----------------Thank You for Shopping!!---------
-----");
System.out.println("\t\t\t\t Visit Again ");
// close Scanner
//sc.close();

}
public boolean search(String ac_no)
{
if (accno.equals(ac_no))
{
showAccount();
return (true);
}
return (false);
}

}
public class Shop
{
public static void main(String arg[])
{
Scanner sc = new Scanner(System.in);

//create initial accounts


System.out.print("How many number of customers do you want to
input? ");
int n = sc.nextInt();
ShopDetails C[] = new ShopDetails[n];
for (int i = 0; i < C.length; i++)
{
C[i] = new ShopDetails();
C[i].openAccount();
}

System.out.println("\t\t\t\t--------------------Invoice---------------- ");
System.out.println("\t\t\t\t\t "+" "+"Sunil Super Shop");
System.out.println("\t\t\t\t\t Dhule(devpur)");
System.out.println("GSTIN: 12AE389Y4J67WE5"+"\t\t\t\t\t\t\tContact:
(+91)1234567890\n");

// loop runs until number 5 is not pressed to exit


int ch;

do
{

System.out.println("__________________________________________
__________");
System.out.println(" 1. Display all account details \n 2. Search by
Account number\n 3. Add Balance to card \n 4.Shop Groceries \n 5.Exit
");
System.out.println("Enter your choice: ");
ch = sc.nextInt();

switch (ch)
{
case 1:
for (int i = 0; i < C.length; i++)
{
C[i].showAccount();
}
break;
case 2:
System.out.print("Enter account no. you want to search: ");
String ac_no = sc.next();
boolean found = false;
for (int i = 0; i < C.length; i++)
{
found = C[i].search(ac_no);
if (found)
{
break;
}
}
if (!found)
{
System.out.println("Search failed! Account doesn't exist..!!");
}
break;
case 3:
System.out.print("Enter Account no. : ");
ac_no = sc.next();
found = false;
for (int i = 0; i < C.length; i++)
{
found = C[i].search(ac_no);
if (found)
{
C[i].deposit();
break;
}
}
if (!found)
{
System.out.println("Search failed! Account doesn't exist..!!");
}
break;
case 4:
System.out.print("Enter Account No : ");
ac_no = sc.next();
found = false;
for (int i = 0; i < C.length; i++)
{
found = C[i].search(ac_no);
if (found)
{
System.out.print("Enter your Shopping List:");
C[i].shopping();
break;
}
}
if (!found)
{
System.out.println("Search failed! Account doesn't exist..!!");
}
break;

case 5:
System.out.println("See you soon...");
break;
}
}
while (ch != 5);
}
}
 Output:

// Open Account & Display Account Details:


// Display all account details.

// Search account no :
//Shop Groceries & Exit.

You might also like