Supermarket

Supermarket

package com.ilp.tcs;

public class Catalogue
{
    String proName,prodesc;
    double price;
    public String getProName() {
        return proName;
    }
    public void setProName(String proName) {
        this.proName = proName;
    }
    public String getProdesc() {
        return prodesc;
    }
    public void setProdesc(String prodesc) {
        this.prodesc = prodesc;
    }
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }


}

package com.ilp.tcs;

public class Customer 
{
    String custName;
    int custId;
    String status;
    public String getCustName() {
        return custName;
    }
    public void setCustName(String custName) {
        this.custName = custName;
    }
    public int getCustId() {
        return custId;
    }
    public void setCustId(int custId) {
        this.custId = custId;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }


}

package com.ilp.tcs;
import java.util.*;

public class SuperMrktMain 
{
    ArrayList<Customer> custlist=new ArrayList<Customer>();
    ArrayList<Catalogue> catlist=new ArrayList<Catalogue>();

    public void Catlog()
    {
        Catalogue c=new Catalogue();
        c.setProName("Nokia");
        c.setProdesc("This is nokia");
        c.setPrice(5000);
        catlist.add(c);

        Catalogue c1=new Catalogue();
        c1.setProName("Samsung");
        c1.setProdesc("This is Samsung");
        c1.setPrice(6000);
        catlist.add(c1);

        Catalogue c2=new Catalogue();
        c2.setProName("Apple");
        c2.setProdesc("This is Apple");
        c2.setPrice(25000);
        catlist.add(c2);

        Catalogue c3=new Catalogue();
        c3.setProName("Micromax");
        c3.setProdesc("This is Micromax");
        c3.setPrice(3000);
        catlist.add(c3);        
        display();

    }

    public void addProd()
    {
        System.out.println("Enter product details");
        Scanner s=new Scanner(System.in);
        String name,desc;
        int price;
        System.out.println("Enter product Name");
        name=s.nextLine();
        System.out.println("Enter product Description");
        desc=s.nextLine();
        System.out.println("Enter product Price");
        price=s.nextInt();
        Catalogue pro=new Catalogue();
        pro.setProName(name);
        pro.setProdesc(desc);
        pro.setPrice(price);
        catlist.add(pro);
        display();
    }

    public void display()
    {
        System.out.println("The products are:");
        for(Catalogue ct: catlist)
        {
            System.out.println(ct.getProName()+" "+ct.getProdesc()+" "+ct.getPrice());
        }
    }

    public void custDetails()
    {
        Customer cust=new Customer();
        cust.setCustName("Himani");
        cust.setCustId(101);
        cust.setStatus("MEMBER");
        custlist.add(cust);

        Customer cust1=new Customer();
        cust1.setCustName("Prachi");
        cust1.setCustId(102);
        cust1.setStatus("MEMBER");
        custlist.add(cust1);

        Customer cust2=new Customer();
        cust2.setCustName("Akshi");
        cust2.setCustId(103);
        cust2.setStatus("NON MEMBER");
        custlist.add(cust2);

        Customer cust3=new Customer();
        cust3.setCustName("Anukool");
        cust3.setCustId(104);
        cust3.setStatus("NON MEMBER");
        custlist.add(cust3);
        regMember();
    }

    public void regMember()
    {
        System.out.println("Enter details");
        Scanner s=new Scanner(System.in);
        String name;
        int id;
        System.out.println("Enter Name");
        name=s.nextLine();
        System.out.println("Enter Id");     
        id=s.nextInt();
        Customer cus=new Customer();
        cus.setCustName(name);
        cus.setCustId(id);
        cus.setStatus("MEMBER");        
        custlist.add(cus);
        System.out.println("Congratulations!!You are now a member :)");
        displayMem();
    }

    public void displayMem()
    {
        System.out.println("Details:");
        for(Customer ct: custlist)
        {
            System.out.println(ct.getCustName()+" "+ct.getCustId()+" "+ct.getStatus());
        }
    }

    public void billing(String status)
    {
        System.out.println("Enter product you want to buy");
        String proname;
        Scanner scan1=new Scanner(System.in);
        proname=scan1.nextLine();
        double amt;
        for(Catalogue ct1: catlist)
        {
            if(ct1.getProName().equals(proname))
            {

                if(status.equals("MEMBER"))
                {
                    if(ct1.getPrice()>2000)
                    {                       
                        amt=ct1.getPrice()-(0.1*ct1.getPrice());                        
                        System.out.println("Amount to be paid is "+amt);
                    }
                    else
                    {
                        amt=ct1.getPrice()-(0.05*ct1.getPrice());                       
                        System.out.println("Amount to be paid is "+amt);
                    }
                }
                else if(status.equals("NON MEMBER"))
                {
                    if(ct1.getPrice()>2000)
                    {                       
                        amt=ct1.getPrice()-(0.05*ct1.getPrice());                       
                        System.out.println("Amount to be paid is "+amt);
                    }
                    else
                    {
                        amt=ct1.getPrice();                     
                        System.out.println("Amount to be paid is "+amt);
                    }
                }
            }

        }
    }

    public void purchasing()
    {
        String status;
        String n;       
        Scanner scan=new Scanner(System.in);
        System.out.println("Enter your name");
        n=scan.nextLine();
        for(Customer cst: custlist)
        {
            //System.out.println("hello ");
            if(cst.getCustName().equals(n))
            {
                 status=cst.getStatus();
                 billing(status);
            }

        }


    }

    public static void main(String[] args) 
    {
        SuperMrktMain m1=new SuperMrktMain();
        int ch;
        do
        {           
        Scanner sc=new Scanner(System.in);
        System.out.println("Menu");
        System.out.println("1.View catalogue");
        System.out.println("2.Add Product to catalogue");
        System.out.println("3.Register Member");
        System.out.println("4.Purchase and billing");
        System.out.println("Enter ur choice");
        ch=sc.nextInt();
        switch(ch)
        {
        case 1:
            m1.Catlog();
            break;
        case 2:
            m1.addProd();
            break;
        case 3:
            m1.custDetails();
            break;
        case 4:
            m1.purchasing();
            break;
        default:
            System.out.println("wrong choice");
        }

        }while((ch>=1) &&(ch<=4));  


    }

}
View Answers









Related Tutorials/Questions & Answers:
supermarket program
supermarket program  i want program in java which is used in supermarkets,medical shops?   Please visit the following links: http://www.roseindia.net/tutorial/java/core/productRegisterSystem.html http
Supermarket
Advertisements
supermarket Automation software
supermarket Automation software   Hello RoseIndia , I want to build a supermarket Automation software that has the features of stock taking and receipt prniting.i want information about supermarket Automation software,can u help
supermarket software - Struts
supermarket software  Hello RoseIndia, I want to build a supermarket software that has the features of stock taking and receipt priting. can u help me with this.. Thanks Advancely
ModuleNotFoundError: No module named 'django-supermarket'
ModuleNotFoundError: No module named 'django-supermarket'  Hi, My... named 'django-supermarket' How to remove the ModuleNotFoundError: No module named 'django-supermarket' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-supermarket'
ModuleNotFoundError: No module named 'django-supermarket'  Hi, My... named 'django-supermarket' How to remove the ModuleNotFoundError: No module named 'django-supermarket' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-supermarket'
ModuleNotFoundError: No module named 'django-supermarket'  Hi, My... named 'django-supermarket' How to remove the ModuleNotFoundError: No module named 'django-supermarket' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-supermarket'
ModuleNotFoundError: No module named 'django-supermarket'  Hi, My... named 'django-supermarket' How to remove the ModuleNotFoundError: No module named 'django-supermarket' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pt-supermarket-scraper'
ModuleNotFoundError: No module named 'pt-supermarket-scraper'  Hi...: No module named 'pt-supermarket-scraper' How to remove the ModuleNotFoundError: No module named 'pt-supermarket-scraper' error? Thanks   Hi
ModuleNotFoundError: No module named 'pt-supermarket-scraper'
ModuleNotFoundError: No module named 'pt-supermarket-scraper'  Hi...: No module named 'pt-supermarket-scraper' How to remove the ModuleNotFoundError: No module named 'pt-supermarket-scraper' error? Thanks   Hi
code - Java Beginners
code  code for supermarket project
NEED CODE FOR APPLICATION - Development process
NEED CODE FOR APPLICATION  i want to build a supermarket software that has the features of stock taking and receipt priting. can u help me
barcode scanner device usage in database application
barcode scanner device usage in database application  Am trying to design a supermarket inventory desktop database application however I can't seem to know how to use a barcode scanner device on my application can anyone put me
How could I use Socket in my application?
How could I use Socket in my application?  I created an application dealing with the management of a supermarket using Hibernate and Swing. I found out today that I have to use also Socket and I don't know exactly what I could do
java
. In this supermarket, the administrators offer discounts to customers basing on the quantities
help me
using the built-in Queue class  Queues are after used to stimulate the flow of people , cars , airplanes , transactions , and so on . write a program that models checkout lines at a supermarket, using the built-in Queue
ADT ,data structure (ArrayList), sorting
ADT ,data structure (ArrayList), sorting  Write a program to calculate a bonus for 10 employees of WAFA Supermarket. The program consists of an abstract class Employee. Each employee contains IC number, name, basicSalary
arraylist
arraylist  Write a program to calculate a bonus for 10 employees of WAFA Supermarket. The program consists of an abstract class Employee. Each employee contains IC number, name, basicSalary, noOfYearService, set methods for each
Most Innovative Retail Companies in the World
_TO_REPLACE_2 Supermarket is arguably the largest retail store in the world in the food
Career in Retail management
whether it is supermarket to departmental stores chain, kiosks, small groceries
Top 10 Web Design Mistakes
on a showroom or supermarket where even though you do not intend to purchase anything

Ads