• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Salesperson array

 
Greenhorn
Posts: 29
Netbeans IDE Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am so stuck on this, I understand the comcept behind the array, but cannot make it past where I am. I have to have an array that compares at least 2 salespersons annual compensation (from previous work), calculates the lower to exceed the higher compensation, and asks for the name of the salespersons.
I have this much figured out:

 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Please use code tags when posting code. That makes it much easier to read. I've added them for you here.

Arrays don't compare things; they provide a place to store things, also known as a data structure. You'll need a method to do the comparison. It seems like you're handling the input right, though you're only storing the compensation value in the array. Maybe you want to define a Salesperson class that contains both a name and a compensation figure. Then you could have an array of Salesperson rather than int. After that, I'm not sure what you're trying to do. I run off the rails at, "calculates the lower to exceed the higher compensation". I just can't parse that at all.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

M Gerber wrote:I am so stuck on this,


Hi M Gerber, welcome to JavaRanch.

Just to add to what Greg said, you should also try to avoid very long lines. They cause windowing problems. I've split yours up this time.
Also: any timetable is your problem. We're all volunteers here.

I think you'd be much better off creating a SalesPerson class. Then an array of them is as simple as:

SalesPerson[] salespeople = new SalesPerson[50]; // for example

HIH

Winston
 
M Gerber
Greenhorn
Posts: 29
Netbeans IDE Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, Thank you for your responses

The point of the code is to take 2 salespersons base sales, add the compensationcalc method to it to get the compensation + accel factor (if qualifies), and then find out which one is higher then what needs to be added to the lower to make it higher (even) to the higher sales number. I am stuck on how to send the salesperson's sales, send it to the compensationcalc method (or call the method?) and then retrieve the data to display.

Winston good info on creating new class of salesperson, Thanks.
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would think that calculating compensation would involve data related to the sales person. For example sales target may be a fixed value now, but what if in the future, you want different sales people have different targets. Therefore, I'd probably get rid of the CommisionCalc class, and put the calculation directly into SalesPerson. One of the basic principles of object-oriented programing is that you should state your problem in plain English, then pick out the nouns to become classes and the verbs to become methods. CommisionCalc looks more like a verb to me.
 
M Gerber
Greenhorn
Posts: 29
Netbeans IDE Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are defenitly correct and I will try to implement your suggestions, but for now the code is still not working. I am a very greenhorn, and this was supposed to be for one of my classes ( I am not asking for the answers, I already posted the original code to the class) I just wanted to see where I was messing up.

I needed to have:
salesperson annual salary = 74,000
sales target of 200,000
commission of 12% after 80% of sales target is achieved
acceleration factor of 1.25 added to total if meets 200,000
display a table of potential commission earnings up to 150% of sales in 5,000 increments
use an array to compare 2 salespeople, find out which one is higher and calculate the difference to add to the lower to meet or exceed the higher.

As you can see I am trying to understand what is needed and how to go about it. My code does calculate the commission, but does not display the table or utilize the array (which is covered in red in Netbeans IDE). I am stumped. any suggestions would be helpful. My class is over Tuesday, this is just for my knowledge to help me understand the work.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simply saying "The code is not working" really gives us nothing to help you with. WHAT is not working? Does it compile? Does it run or does it crash? Does it give the wrong output? What output did you expect? What input did you give it?

Honestly, if this is really for your own benefit, I would say throw it all away, and start over. But do it right. For the first few hours, don't think in java, think in English. Literally, write down what your program needs to do. Break it apart into separate components. For example, how you get an input is COMPLETELY independent of what you do with the input. Regardless of whether you prompt the user, read it from a database, open a socket, or any other method, your methods/classes that USE it don't care.

When you do get to it, write your code in small chunks - I only write 2-3 lines at a time before i recompile and test. and I test the hell out of it each time.

I would probably write a method that takes an int as the sales amount, and calculates the compensation for that amount.
 
Marshal
Posts: 28009
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ceaser tefutor,
Your post was moved to a new topic.
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic