Wednesday, September 4, 2019

String And Numeric Array Program On Sales Report


This is a BlueJ Program on Sales Report. This BlueJ program will print a sales bill according to the following specifications: Input the date of purchase, name of the buyer, name of item + no of purchase + price of item. Calculate total amount and add 12% GST to show the final payment amount.

Format as follows:

Customer Name    Date

Item    Price    Quantity    Amount
---        ----       -------         ------
---        ----       -------         ------
---        ----       -------         ------
                       Total          -----
                       GST           ---
                       Grand Total –





import java.util.Scanner;
class Star
{
int i,n, pcs[];
double price[];
String items[];
String name,d;
double gst=12;
double amt,total=0;
Scanner sc=new Scanner(System.in);
public void read()
{
   System.out.print("\nDate: ");
   d=sc.nextLine();
   System.out.print("\nName of Customer: ");
   name=sc.nextLine();
   System.out.print("\nHow many items to Purchase: ");
   n=sc.nextInt();
   price=new double[n];
   pcs=new int[n];
   items=new String[n];
   for(i=0;i< n;i++)
  {
     System.out.print("\nItem Name: ");
     items[i]=sc.next();
     System.out.print("\nNo of Pcs: ");
     pcs[i]=sc.nextInt();
     System.out.print("\nPrice: ");
     price[i]=sc.nextInt();
 }
}
 public void show()
 {
     System.out.print("\nCustomer Name: "+name);
     System.out.println("  Date: "+d);
     System.out.println("\nItem Name   Price    Quantity    Amount");
     for(i=0;i< n;i++)
     {
         System.out.print(items[i]+ "        " + price[i]+ "       "+ pcs[i] + "        "); 
         amt=price[i]*pcs[i];
         total=total+amt;
         System.out.println(amt);
     }
       System.out.println( "                       Total " + total); 
       gst=total*gst/100;
       System.out.println( "                       GST " + gst);
       total=total+gst;
       System.out.println( "       Grand Tootal " + total);
    }
public static void main(String args[])
{
 Star ob=new Star();
 ob.read();
 ob.show();
  }
}


Related Post: BlueJ Programs on Numeric Array
                        BlueJ Programs on String/Sentence

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner