Sunday, August 18, 2019

BlueJ Program on Sales Report of Salesmen Using Array




This is a BlueJ program on sales report. 2-D array is used in this program to store sales of number of salesmen.


A company has 10 products being sold by 5 salesmen. Sales details are stored in an array S[][].
 Write a program in Java to
 (i)Total sales of each product
 (ii) Total sales made by each each salesman


For each salesman 1 row and for 10 products 10 columns are required. For 5 samesmen, total 5 rows to be created. So the array size will be 5X10.
Column number 0 will hold the product number 1 sales record, column number 2 will hold sales record of product number 2 and so on


import java.util.*;
public class Sales
{
    Scanner sc=new Scanner(System.in);
    int S[][]=new int [5][10];
    int sum,i,j;
    public void takeDatas()
    {
         
          for(i=0;i<=4;i++)
         {
              System.out.println("\nEntering sales record for Salesman Number: "+(i+1));
            for(j=0;j<=9;j++)


            {
           
            System.out.print("Product Number "+(j+1)+":");
            S[i][j]=sc.nextInt();
           
            }
        }
        System.out.println("\nDetails Sales Report");
        for(i=0;i<=4;i++)
         {
             for(j=0;j<=9;j++)
            {
             System.out.print(S[i][j]+" ");
            }
            System.out.println();
        }
         
         show();
    }
            private void show()
            {
                 System.out.println("\nSales Report of Each Product");
                 for(i=0;i<=9;i++)
                 {
                     sum=0;
                      for(j=0;j<=4;j++)
                 {
                     sum=sum+S[j][i];
                 }
                    System.out.println("\nSales Report of Product No "+(i+1)+":"+sum);
                 }
                
                 System.out.println("\nSales Report of Each Salesman");
                 for(i=0;i<=4;i++)
                 {
                     sum=0;
                      for(j=0;j<=9;j++)
                 {
                     sum=sum+S[i][j];
                 }
                    System.out.println("\nSales Report of Salesman No "+(i+1)+":"+sum);
                 }
                }
               
                  
            public static void main(String args[])
            {
                 Sales obj=new Sales();
                 obj.takeDatas();
             }
            }


Related Post: BlueJ Programs on Numeric Array

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner