Sunday, December 29, 2019

BlueJ Program on Salesmen and Commission


A Companies salesmen are selling talcum powder and tooth powder. The company gives 15% commission  on the sale of talcum and 20 % commission on sale of tooth powder. Write a program to compute and print total sale and total commission of each salesman assuming that there are 100 salesmen in the company. Also separately compute total sale it made for talcum powder and tooth powder and the total amount of commission the company paid to salesmen.

import java.util.*;
public class Commission
{
   
    String name;
    int talcum, tooth, ttalcum=0, ttooth=0;
    double comm, tcomm=0;
  
    public void salary()
    {
        for(int i=0;i<=99;i++)
        {
            
            Scanner sc=new Scanner(System.in);
             System.out.print("\nName of Salesman:");
             name=sc.nextLine();
             System.out.print("\nTotal sale of talcum powder by the salesman:");


             talcum=sc.nextInt();
             System.out.print("\nTotal sale of tooth powder by the salesman:");
             tooth=sc.nextInt();
             comm=talcum*15.0/100+tooth*20.0/100;
             tcomm=tcomm+comm;
             ttalcum=ttalcum+talcum;
             ttooth=ttooth+tooth;
             System.out.print("\nCommission of "+ name+ " :"+comm);
             sc.close();

    }
     System.out.print("\nTotal Commission paid :"+tcomm);
      System.out.print("\nTotal sale of talcum powder :"+ttalcum);
     System.out.print("\nTotal sale of tooth powder :"+ttooth);
}
public static void main(String args[])
{
     Commission ob=new Commission ();
     ob.salary();
    }
}


No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner