Friday, July 3, 2020

Java Program On Retail Shop Billing


Title - retail outlet
Details - 
Customer's name and phone number should be entered.
A welcome message will be displayed.
The product names (at least 12 product ) will be displayed. ( given previously to the program along with prices during the quantity for one each product. ) 
Shopkeeper produces a bill by typing product name .
The bill must display the following 
A bill number.
Name of the shop.
Name and phone number of the customer.
GST amount ( 18% of total amount ) 
Total amount ( calculated as sum of price of all products)


import java.util.*;
 class RetailOutlet
 {
     double amt=0;
     int i,pc,x=0;
     long phoneno;
     String name,s,item;
     char ch;
     String product[]={"A","B","C","D","E","F","G","H","I","J","K","L"};
     String bill[]=new String[15];
     double rate[]={10.5,20,25,30,12.5,22,23,30,14.5,21,21,31};
     /* Set the item names and price properly*/
     Scanner sc=new Scanner(System.in);
     void takeData()
     {
         
         System.out.print("\nEnter Name:");
        name=sc.nextLine();        
        System.out.print("\nEnter Phone Number:");
         phoneno=sc.nextLong();
System.out.print("\nWelCome :" + name + " Phone Number: "+phoneno);
         
        } 
        void sellItems()
        {
            System.out.print("\nHere Is List Chart of Items of GOPAL STORES\n");
            for(i=0;i<12;i++)
            System.out.print("\n"+product[i]+ "  Rate:  "+rate[i]);
            ch='y';
            while(ch!='n')
            {
               sc=new Scanner(System.in);
               System.out.print("\nItem Name: "); 
               item=sc.nextLine();
               for(i=0;i<12;i++)
               {
                   if(item.equalsIgnoreCase(product[i]))
                   break;
                }
                if(i==12)
                System.out.print("\nEnter Item Name Properly ");
                else
                {
                     System.out.print("\nHow many Pcs: ");
                      pc=sc.nextInt();
                     s=item + " Price Per Unit: "+ rate[i]+ " " + pc+ " Pcs. " + " Total Rs.: " + rate[i]*pc;
                     bill[x++]=s;
                     amt=amt+rate[i]*pc;
                }
                 System.out.print("\nAny More Item, Press 'n' to produce the Final Bill otherwise 'y' ");   
                    ch=sc.next().charAt(0);
                    ch=Character.toLowerCase(ch);
                    sc=null;
                }
                
                s="Gross Bill Rs.: " + (amt- amt*18/100);
                     bill[x++]=s;
                     s="GST Rs.: " + amt*18/100;
                     bill[x++]=s;
                     s="Payable Amount Rs.: " + amt;
                     bill[x++]=s;         
            
        }
        void display()
        {
           System.out.print("\n GOPAL STORES\n"); 
            System.out.println("Customer: "+name); 
           System.out.println("Phone Number: "+phoneno); 
           for(i=0;i<x;i++)
           System.out.println(bill[i]);
        }
        public static void main(String args[])
        {
            RetailOutlet obj=new RetailOutlet();
            obj.takeData();
            obj.sellItems();
            obj.display();
        }
    }
            

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner