Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Sunday, 2 October 2011

Java program to calculate commission on sales using methods (by Adler Lawn Service,LLC)

 import java.util.*;
class commission2
{
public static void main (String args[])
{
Scanner in =new Scanner (System.in);
double sales_figure,commission_rate_d;
int commission_rate_i;
System.out.print ("\n\t Enter sales figure = ");
sales_figure=in.nextDouble();
System.out.print ("\n\t Enter first commission rate = ");
commission_rate_d=in.nextDouble();
System.out.print ("\n\t Enter second commission rate = ");
commission_rate_i=in.nextInt();
comm2 ob2 = new comm2();
totalcomm ob = new totalcomm();
ob.computeCommission(sales_figure,commission_rate_d);
ob.computecommission(sales_figure,commission_rate_i);
ob2.computeCommission(sales_figure);
}
}

class comm2 extends totalcomm
{
void computeCommission (double sales)
{
double cr;
cr=(7.5/100)*sales;
System.out.println ("\n\t Commission at 7.5% = "+cr);
}
}

class totalcomm
{
double sales_fig,comm_rate;
int com_rate;
void computeCommission(double p1, double p2)
{
sales_fig=p1;
comm_rate=p2;
System.out.println ("\n\t Sales commission = "+(sales_fig*comm_rate));
}
void computecommission(double p1, int p2)
{
sales_fig=p1;
com_rate=p2/100;
System.out.println ("\n\t Commission = "+(sales_fig*com_rate));
}
}

6 comments:

  1. I need a java program to do the following:

    Every salesperson has a basic salary.the salesperson also receives a bonus at the end of each month based on the following;

    if the salesperson has work for 5 years or less,the bonus is $10 for each year he has work there.
    if the salesperson has work more than 5 years, the bonus is $20 for each year he has work there.
    the sales person can earn additional bonus :
    if the total sale made by the salesperson for the month are greater than or equal to $5,000 but less than $10,000, he get 3% commission on the sale.
    if the total sale made by the salesperson for the month are $10,000 or more, he get 6% commission on the sale.

    ReplyDelete
  2. Nice, I have problem to solve this question: A large insurance company in USA pays its sales agent on a commission basis. The sales agent receives N$600 per week plus 20% of the gross sales for that week. For example a sales agent who sells N$8000 worth of insurance plans in a week receives N$600 plus 30% of N$8000. Write a Java Program to displays the sales agent salary per week and the salary per month. The salary per month is calculated as salary per week times four. can someone help me to solve please!

    ReplyDelete
  3. I need a java program about this problem of Sales Commission Calculator.

    A large company pays its salespeople on a commission basis. The salesperson receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9% of $5000, or a total of $650. You've been supplied with a list of the items sold by each salesperson. The values of these are as follows:
    Item Value
    1. 239.99
    2. 129.75
    3. 99.95
    4. 350.89

    Develop a Java application that inputs one salesperson's items sold for last week and calculates and displays that salesperson's earnings. There's no limit to the number of items that can be sold.

    ReplyDelete
    Replies
    1. import java .util.*;

      public class Salary {

      public static void main(String[] args)
      {
      float sdollars,salary;
      int choice=1;
      Scanner input=new Scanner(System.in);
      while(choice==1)
      {
      System.out.println("Enter sales in dollars:");
      sdollars=input.nextFloat();
      sdollars=(sdollars*9)/100;
      salary=200+sdollars;
      System.out.printf("Salary is: %.2f\n",salary);
      System.out.println("Do you want to enter another data?(1 for yes & 0 for no)");
      choice=input.nextInt();
      }//while ends
      }}

      Delete
  4. but if i want to get multyple input and then calculatethen what logic is applied..?

    ReplyDelete
  5. Question 1 (55 Marks)
    Write a complete Java program using enum to calculate total monthly income for Hanis Tourist Agent. You must write two complete Java programs, Agent.java and TestAgent.java based on the instruction given in (a) and (b).
    a) Write a class named Agent. The class uses enum data type and should have a double field named cost that holds the travelling cost and a double field named commission that holds the commission rate. There are four packages offered by Hanis Tourist Agent as shown in Table 1.
    Table 1: Hanis Tourist Agent package
    Package
    Package Offered
    Commission Rate
    Nilam
    RM 2020.00/person for 5D4N Adelaide
    14% per cost per person
    Aqiq
    RM 1440.00/person for 5D4N Gold Coast
    8% per cost per person
    Delima
    RM 1490.00/person for 5D4N Melbourne
    10% per cost per person
    Zamrud
    RM 2075.00/person for 5D4N Perth
    15% per cost per person
    In addition, the class also provides the following methods:
    (i) A constructor for class Agent that accepts the travelling cost and the commission rate as the arguments. It should set the cost field and commission field to the value passed as the arguments.
    (ii) Write suitable code for the getter (accessor) methods.
    (iii) Write method named readInput() to read input for numPerson from keyboard. The variable holds the number of person for each package. Use Scanner class for this purpose.
    (iv) Write method named calcCommission()to return the total commission will be received for each package.
    b) Write a class TestAgent that only has main() method with the following codes:
    (i) Ask the user to enter input for numOrder from keyboard. The variable holds the number of package ordered by customer.
    (ii) Creates Agent objects based on numOrder entered by user.
    (iii) Read input for each object created.
    (iv) Calculate and display the total monthly income will be received for all ordered packages.



    The program should produce the output as shown in Figure 1(a) and 1(b). Note that the text in bold indicates input entered by the user.

    Number of package ordered: 2
    Package [NILAM, AQIQ, DELIMA, ZAMRUD]
    Package [1]
    Package type: Delima
    Package info: RM 1490.00/person for 5D4N Melbourne
    Commission rate: 10.0% per total cost
    Number of person(s): 4
    Total cost: RM5960.00
    Total commission: RM596.00
    Package [2]
    Package type: AQIQ
    Package info: RM 1440.00/person for 5D4N Gold Coast
    Commission rate: 8.0% per total cost
    Number of person(s): 6
    Total cost: RM8640.00
    Total commission: RM691.20
    TOTAL INCOME: RM1287.20
    Press any key to continue . . .

    ReplyDelete