Sales Commission

calculate sales commission and display the results in a table

Page 1 of 1

7 Replies - 18360 Views - Last Post: 18 October 2010 - 02:24 PM Rate Topic: -----

#1 Mrbond56  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 13-October 10

Sales Commission

Posted 18 October 2010 - 10:47 AM

I have to take in total sales people sold and display how many people earned in each commission rate as seen below as an int within an array
a) $200-299
B)/> $300-399
c) $400-499
d) $500-599
e) $600-699
f) $700-799
g) $800-899
h) $900-999
i) $1000 and over



my programs code so far

import java.util.Scanner;

public class Sales
{
	public static void main( String[] args )
	{
		int sales;
		int commission;
		static final int S_pay = 200;
		int f_pay;
		static final int c_rate = 1.09;
		
		System.out.printl("Please enter the sales amount -1 to exit")
		sales = input.nextInt();
		
		while ( sales != -1 )
		{
			System.out.printl("Please enter the sales amount -1 to exit");
			sales = input.nextInt();
		}
		
		commission = sales * c_rate;
		f_pay = commission + sales;
		
	}
}




output should look like this

Range          Number
$200-$299      9
$300-$399      1
$400-$499      0
$500-$599      0
$600-$699      0
$700-$799      0
$800-$899      0
$900-$999      0
$1000 and over 0



This post has been edited by Mrbond56: 18 October 2010 - 10:52 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Sales Commission

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Sales Commission

Posted 18 October 2010 - 10:57 AM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with DONE
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

This post has been edited by JackOfAllTrades: 18 October 2010 - 10:58 AM

Was This Post Helpful? 0
  • +
  • -

#3 Mrbond56  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 13-October 10

Re: Sales Commission

Posted 18 October 2010 - 11:03 AM

View PostJackOfAllTrades, on 18 October 2010 - 09:57 AM, said:

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with DONE
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Should I make an array to handle the results of the sales people pay and the range that should display how many sales people earned pay in each of the different ranges?

the compiling errors that I'm getting are in lines 9 and 11 in my program code so far where I'm declaring constant variables that are being used to calculate the sales people gross pay

The program should determine how many salespeople earned salaries listed above in the first part of my post and display the results in a tabular form as listed under my program code so far

This post has been edited by Mrbond56: 18 October 2010 - 11:10 AM

Was This Post Helpful? 0
  • +
  • -

#4 Mrbond56  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 13-October 10

Re: Sales Commission

Posted 18 October 2010 - 12:15 PM

View PostMrbond56, on 18 October 2010 - 10:03 AM, said:

View PostJackOfAllTrades, on 18 October 2010 - 09:57 AM, said:

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with DONE
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Should I make an array to handle the results of the sales people pay and the range that should display how many sales people earned pay in each of the different ranges?

the compiling errors that I'm getting are with line 24 and this is the error that comes with it after taking off the static from the constant variables
found : double
required: int
commission = (int)sales * c_rate;
^



The program should determine how many salespeople earned salaries listed above in the first part of my post and display the results in a tabular form as listed under my program code so far

Was This Post Helpful? 0
  • +
  • -

#5 Mrbond56  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 13-October 10

Re: Sales Commission

Posted 18 October 2010 - 01:10 PM

Should I make an array to hold the values of the possible sales amount and for the number of people who get that amount?

here is my updated code that has no errors
import java.util.Scanner;

public class Sales
{
	public static void main( String[] args )
	{
		int sales;
		int commission;
		final int S_pay = 200;
		int f_pay;
		final double c_rate = 1.09;
		
		Scanner input = new Scanner( System.in );
		
		System.out.println("Please enter the sales amount -1 to exit");
		sales = input.nextInt();
		
		while ( sales != -1 )
		{
			System.out.println("Please enter the sales amount -1 to exit");
			sales = input.nextInt();
		}
		
		commission = (int)(sales * c_rate);
		f_pay = (int)(commission + sales);
		
	}
}



I want the results of all the sales people who earned a pay check between these amounts to be listed in a table form and displayed in the code that is listed under the output code in post 1
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12189
  • View blog
  • Posts: 45,251
  • Joined: 27-December 08

Re: Sales Commission

Posted 18 October 2010 - 01:16 PM

A Map is the best structure to use here. You can store a TreeMap<Integer, List<String>>, where Integer is the key for the minimum amount of each tier (ie., 200, 300, etc.), and the List<String> is the corresponding value that holds the names of the salespeople. The benefit of using a TreeMap is that it will sort by the Keys (the tiers), making it easy for you to just iterate through and print out the names.

For more information on TreeMap, check out the API: http://download.orac...il/TreeMap.html
Was This Post Helpful? 0
  • +
  • -

#7 Mrbond56  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 13-October 10

Re: Sales Commission

Posted 18 October 2010 - 01:30 PM

View Postmacosxnerd101, on 18 October 2010 - 12:16 PM, said:

A Map is the best structure to use here. You can store a TreeMap<Integer, List<String>>, where Integer is the key for the minimum amount of each tier (ie., 200, 300, etc.), and the List<String> is the corresponding value that holds the names of the salespeople. The benefit of using a TreeMap is that it will sort by the Keys (the tiers), making it easy for you to just iterate through and print out the names.

For more information on TreeMap, check out the API: http://download.orac...il/TreeMap.html

The output should look like this if possible
Range          Number
$200-$299      9
$300-$399      1
$400-$499      0
$500-$599      0
$600-$699      0
$700-$799      0
$800-$899      0
$900-$999      0
$1000 and over 0


Was This Post Helpful? 0
  • +
  • -

#8 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12189
  • View blog
  • Posts: 45,251
  • Joined: 27-December 08

Re: Sales Commission

Posted 18 October 2010 - 02:24 PM

I completely misunderstood what you were trying to accomplish. Sorry about that. :)

It would probably be easier then to store an int[] of length 10, and increment the appropriate elements based on the inputs (ie., increment array[0] if you get a sale between $200-$299).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1