Share on Google+Share on Google+

Devang
Supermarket
0 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners
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));  


    }

}

Ads

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
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
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
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
java
. In this supermarket, the administrators offer discounts to customers basing on the quantities
Most Innovative Retail Companies in the World
innovative retail companies in the world. Supermarket Supermarket is arguably
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
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
Career in Retail management
it is supermarket to departmental stores chain, kiosks, small groceries shops etc
Top 10 Web Design Mistakes
to action. It is more like landing on a showroom or supermarket where even
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads