• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Homework help

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are the requirements for the assignment:
The company has recently changed its total annual compensation policy to improve sales.
A salesperson will continue to earn a fixed salary of <Add salary figure from Week Two here>. The current sales target for every salesperson is < Add a target sales figure here (e.g. $120,000)>.
The sales incentive will only start when 80% of the sales target is met. The current commission is <Add percentage here> of total sales.
If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is <Add a number greater than 1 (e.g. 1.25)>.
The application should ask the user to enter annual sales, and it should display the total annual compensation.
The application should also display a table of potential total annual compensation that the salesperson could have earned, in $5000 increments above the salesperson’s annual sales, until it reaches 50% above the salesperson’s annual sales.
Sample Table: Assuming a total annual sales of $100,000, the table would look like this:
Total Sales Total Compensation
100,000 <<Program calculated value>>
105,000 <<Program calculated value>>
110,000 <<Program calculated value>>
115,000 <<Program calculated value>>
120,000 <<Program calculated value>>
125,000 <<Program calculated value>>
130,000 <<Program calculated value>>
135,000 <<Program calculated value>>
140,000 <<Program calculated value>>
145,000 <<Program calculated value>>
150,000 <<Program calculated value>>

The Java™ application should also meet these technical requirements:
The application should have at least one class, in addition to the application’s controlling class.
The source code must demonstrate the use of conditional and looping structures.
There should be proper documentation in the source code.

This was my original code (part 1) that I am to add to.


It does compile and run correctly.
So what I cannot figure out is how to make the loop and the table. The examples in the book are not complete which is very confusing. I have to have this turned in tonight and am so totally lost it is horrible. Can anyone please help explain?
 
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have added code tags to your post. Always use the tags: doesn't it look better

I am afraid you are going to have to delete that code and start again. Not only have you got too much code in the main method, but also you have no opportunity to add another class. So any extensions you create to that code will fail to fulfil one of the requirements, viz multiple classes. You will not be able to pass if you keep going like that.
Create yourself a Commission class with the appropriate fields, getXXX methods, constructor, toString method, and then a CommissionDemo class with a method like this:-Get that lot working and you will be a long way towards creating your final app.

Why are you using option panes for keyboard input? That is very a old‑fashioned style of programming. Don't you know how to use a Scanner?
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My instructor marked me off for not having an extra class, but the book had said that the JOptionPane was a class. I read the link that you sent and have spent the better part of the day trying to read everything thing that I could to determine how to set this up correctly. I have also read up on the import java.util.Scanner as this was briefly discussed in the book and no where near as much information as what was on the JPane. Thank you for your advice so far I am hoping you or someone could explain using different classes in a way that I could understand and hopefully get this done today as it is now late. Please any advice would be appreciated.
 
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote:My instructor marked me off for not having an extra class, but the book had said that the JOptionPane was a class.


You must be interpreted wrongly what instructor mentioned to you. Likely he had in mind, that you are asked to define and write more than 1 class to accomplish your task.
JOptionPane indeed is a class, but defined not by you. P.S. I could be wrong about what your instructor had in his mind - better ask him.

So, Campbell Ritchie already gave you suggestion what you need to do. Did you understand in general what he meant? If yes, what kind of troubles you're facing of creating Comission class?
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the reply. "Think of a class as a .java file If you create a main class then you can create another class (.java file) that will be called within the main one and used for something like saving values in attributes or calling other methods." This is exactly what my instructor said. The book had said that it was a class so I miss understood what the book was trying to state. That does still leave the fact that I apparently do not understand how to create another class. I am trying to take it back to the start on where I got messed up. The code that I posted was from last weeks assignment. So I guess the new quest is to learn the proper way to correct it.
 
Liutauras Vilda
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Briefly how you could think about 2 classes.
Output
Apple: Spartan
Taste: Sweet

Similarly you need to come up with your task. Create a "Comission" class, where all job is done, and the other class, where your program flow appears.

[Edit:] Ok, we see now what your instructor had in his mind. So read again what CR mentioned to you, check my example of those 2 classes and try to come up with yours. Post it here later, so we could have a look and help if needed.
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay so this is what I think the requirements are asking for:
This is:
Simple Commission Calculation Program
Items needed:
Personal information
– What is your name?
– What is your annual salary?
– What are your annual sales? // target for all sales persons is $120,000
// if the sales person exceeds incentive increases by 1.25%
Calculation
- Calculate sales * incentive = commission (if sales is 80% met)/ if not no incentive
- Calculate total compensation = commission + salary
Table should display what could be earned by increments of $5,000
// table in total sales
Total Sales
100,000
105,000
110,000
115,000
120,000
125,000
130,000
135,000
140,000
145,000
150,000

That means that my classes should be: Personal Information, Calculation, and Table. Would an if-then-else also be needed to determine the calculation?
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So my first class should look like?

 
Liutauras Vilda
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote:That means that my classes should be: Personal Information, Calculation, and Table.


Probably better class would be if sounded not "Personal Information", but "Person". Class should represent a singular object, in this case - person.Person object also should have fields: "anual salary", "anual sales". These fields should be "private, as you don't want someone else to change their salary by mistake, or mess up with sales figures.
So it should start similar to:
Similarly you should create class "Commission".
What do you think "Table" class should represent? Is it needed? Maybe "Commission" class could have a method to print the table?
 
Campbell Ritchie
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should create compile and test classes like Commission before you even think of a CommissionDemo class. I told you last week what to do.

Don't even think about how to do the calculations either, not until you have the other classes worked out. Don't say you need an if‑then‑else for the calculations (or similar) until after you have worked out the formulae.
 
Mona Stout
Greenhorn
Posts: 29
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you might have me confused with someone else. I have not asked for help until last night. I did figure out how to do this finally. I cannot say that it is pretty, but I am glad that at least I have learned a few new terms, have a few that I still need to research (they have not been taught in the class yet), and my program works.




I started to rewrite with scanner, but I did not understand that as well. I need to do more research on it. It is not at all pretty and as I learn more and practice I am sure I will get a handle on it.
I do have to say that I have gotten more help here than what I have in my class, and want to thank everyone who posted to me trying to help.
 
Campbell Ritchie
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote:. . . I have not asked for help until last night. . . .

That was last week.

Please don't hand that in. You haven't written object‑oriented code. I have already told you what to do and Liutauras has given you an example of something similar which you can emulate to suit you own requirements. You should follow those suggestions if you want a decent mark.
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just so that you know I was not ignoring you and that I am taking your information to heart, as this is why I came here to get help. Is this better?


I am trying to understand.
 
Liutauras Vilda
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again Mona,

Mona Stout wrote:Just so that you know I was not ignoring you and that I am taking your information to heart, as this is why I came here to get help. Is this better?

It is understandable, you just learning. Now about the code, we need to be honest - not much improved. It seems you misunderstand the concept.

The best approach probably would be to stop coding at this stage and get the piece of paper and pencil. Write down again for yourself (post it here what you come up with):

1. How many classes you're likely going to need. How these classes could be named? You can find the answer in homework requirements as well as in this thread's posts above.

2. When you decide which classes you're going to write, write down which variables (these are called fields/members) your class is going to have.
For example: Person class should contain variables which holds "person name", "person salary", "person annual sales" and similar information.
Also, this class suppose to contain methods which are related with this Person class. Methods should be like:
"setName", "getName", "setSalary", "getSalary", "setAnnualSales", ...

3. Do the same with all classes on a piece of paper, so write down what information these classes should encapsulate - post it here, guys over here will have a look and will give you some remarks, in this way you'll save a lot of time. At the moment you're spending time in writing code, which after a bit research gives a clear understanding, that it is not correct from the very beginning, so it wasting your time writing it (don't worry, you're learning).

4. The the class "ComissionCalc" should be created at the end, so it could set some values and execute your program, that is it.

5. Don't stress out about the homework due dates, better to grasp the topic now, rather than too much worry about the mark at the moment. By the way, when is your homework due?
 
Campbell Ritchie
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote:. . . Is this better?
. . .

Afraid not. Wherever name is, it should have private access, so you cannot access it outside its own class. If Person is a class, then that code suggests that name is static, which means all Persons share the same name. If there is a Name class, you should not give it a no‑arguments constructor. I mentioned that here yesterday. Please read the whole thread. You want to be able to write
... new Name("Mona", "Stout") ...
so you arrange the constructor to take first name and last name (or similar). By doing so, and getting rid of other constructors, you force users to provide both halves of the name. If you are feeling sophisticated and assertive, you can add some sort of verification of the names to the constructor.
If you are going to use the Person class like that, you want the name in the constructor. You might call
... new Person(new Name("Mona", "Stout")) ...
or
... new Person("Mona", "Stout") ...
and by restricting the range of constructors available, you constrain users to provide the required info. That second constructor might be written like thisNow you have a Person class which will have the required info unless users do something daft. Verification is possible as I said earlier.

As Liutauras is telling you at the moment told you half an hour ago, you can add things like salary to the Person class.
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay you have given me much to think about. I will start writing it out on paper.
To answer the question about when it is due.. well it is a five week excelerated class (just starting week 4) with a portion due each Saturday.
Like i said earlier i am learning more here and wish i had found ya'll earlier.
 
Mona Stout
Greenhorn
Posts: 29
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Liutauras, Campbell, and everyone,

I hope I understood what you asked me to do.

Information to collect:
Salesperson – Who
Salary – How much
Sales – How much

Process:
Calculation - action required
Table - action

Person relates to the salesperson, Salary, and Sales.

Process relates to the actions required for project:
Commission percentage of sales
Percent = Set amount 4%
(after 80% of sales is achieved)
Compensation fixed salary + compensation earned
Incentive if sales is above sales expected $120,000 (additional 1.25%)
Table showing potential commission ($5,000. Increments)

NAME OF PROJECT - Simple Commission Calculator Project - (SimpleCommission)

Person, Process - Classes

Person - fields

Name: String
Salary : double
Sales : double

Person - method

setName
getName
setSalary
getSalary
setSales
getSales



Process - fields

Commission : double
Percent : double
Compensation : double
Incentive : double
Table : table ??

Process - method

setCommission
getCommission
setPercent
getPercent
setCompensation
getCompensation
setIncentive
getIncentive
 
Campbell Ritchie
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's looking a lot better, isn't it.

Consider whether you should or should not hardcode the 4% after 80% bit, or whether you should pass 4% and 80% as parameters to a method.
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Honestly, I think the instructions are about as clear as mud for this assignment so I am trying to break them down a bit here. In the first part the directions said: A salesperson will earn a fixed salary of <Add a salary figure here>. This is to be input by the user Commission is a percentage of the salesperson’s annual sales. The current commission is <Add a percentage here> I just picked 4% of total sales. The total annual compensation is the fixed salary plus the commission earned.

Then it went on in the second part: The current sales target for every salesperson is < Add a target sales figure here (e.g. $120,000)>I used $120,000.. The sales incentive will only start when 80% of the sales target is met. The current commission is <Add percentage here>I just picked 4% of total sales. If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is <Add a number greater than 1 (e.g. 1.25)>I used 1.25%. The application should ask the user to enter annual sales, and it should display the total annual compensation. The application should also display a table of potential total annual compensation that the salesperson could have earned, in $5000 increments above the salesperson’s annual sales, until it reaches 50% above the salesperson’s annual sales.

In the third part is says: The application will now compare the total annual compensation of at least two salespersons. It will calculate the additional amount of sales that each salesperson must achieve to match or exceed the higher of the two earners. The source code must demonstrate the use of Array or ArrayList.

Looking at everything I forgot to add targetSales as a double, setTargetSales, getTargetSales to my lists.

For any sales person they will give the salary, and their sales, but when they reach 80% of their sales their commission is 4% of the total sales until then their commission is 0. If they hit the target sales of $120,000 then they get an additional 1.25. I picked some of the numbers involved, but the way I am understanding it these should be concrete numbers so they won't change. So at 80% of sales they get 4%, if they reach the target then they get an additional 1.25.
We haven't really covered the arguments/parameters yet and I was just able to do a quickie reference check to try to answer your question.
 
Campbell Ritchie
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So if your target is $100000 and you sell $79999.99 your commission is 0.
If you sell $80000 then your commission is 4% of that, i.e. $3200. If you sell $99999.99 your commission will be $3999.99 but if you hit $100000 that goes up to $5000.
You are not paid on the amount of sales over 80%, but on the whole amount of sales, I take it.

It would appear that only the 80% should be hardcoded; the $120000 and the 4% and the 1.25× can all vary. You can pass such parameters to salespeople
You ought not to use doubles for money, but we shall let you use them this time because otherwise we shall be giving you information overload.
You should be running code similar to what it shows there to test your SalesPerson/Person/Commission classes.
 
Liutauras Vilda
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, Mona, now you started actually analyse your problem. I see CR already gave you test cases. I just checked few posts above, so it could help you to concentrate on a parts, which you have to come up:
SalesPerson class

Mona Stout wrote:Personal information
– What is your name?
– What is your annual salary?
– What are your annual sales? // target for all sales persons is $120,000
// if the sales person exceeds incentive increases by 1.25%
Calculation
- Calculate sales * incentive = commission (if sales is 80% met)/ if not no incentive
- Calculate total compensation = commission + salary

 
Campbell Ritchie
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought your 1.25 meant that the commission is increased to 1.25×, i.e. by 25%. So your nearly $4800 (4%) if you sell $119999.99 goes up to $6000 ((4×1.25)% = 5%) if you sell $120000 (or maybe $120000.01).
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Their commission is 4% of their sales but only when they have met 80% of their sales. The incentive kicks in if they get $120,000 then they get an additional 1.25%
So their target is $120,000 and 80% of that is $96000 they will get 4% which is $4800 if they get the 120,000 then their commission is 6300 right?
 
Liutauras Vilda
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote:The incentive kicks in if they get $120,000 then they get an additional 1.25%

No. When exceeds, it means, when they sell more than their target is. Starting from 120.000,01.
 
Liutauras Vilda
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once again, here is what you wrote:

Mona Stout wrote:– What are your annual sales? // target for all sales persons is $120,000
// if the sales person exceeds incentive increases by 1.25%


So:
a) 80% of 120.000 target = 120.000 x 0.8 = 96000
bonus: 96000 x 0.04 = 3840

b) 100% of 120.000 target = 120.000
bonus: 120000 x 0.04 = 4800

c) 110 % of 120.000 target = 120000 + (120000 x 0.1) = 132000
bonus: 132000 x (0.04 x 1.25) = 6600

You better check exact requirements again if you copied correctly, as you could loose some portion of your mark.
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your right exceeds, so it would be at 120,000.01 the percentage would increase to 0.05 not 5.25
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So are we in agreement that the math is now correct via the above posts?
What would be my next step?
I have the classes defined correctly?
Liutauras you said,

Ok, Mona, now you started actually analyse your problem. I see CR already gave you test cases. I just checked few posts above, so it could help you to concentrate on a parts, which you have to come up:
SalesPerson class
Mona Stout wrote:
Personal information
– What is your name?
– What is your annual salary?
– What are your annual sales? // target for all sales persons is $120,000
// if the sales person exceeds incentive increases by 1.25%
Calculation
- Calculate sales * incentive = commission (if sales is 80% met)/ if not no incentive
- Calculate total compensation = commission + salary



The SalesPerson class has to have two people for an Array/Array List comparison
So I would have to label them SalesPerson1 and SalesPerson2, correct? Then do a set() and get() for each one of them.
Does this apply for everything that I do for one I have to write for both or did I misunderstand that part in the book?

 
Liutauras Vilda
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote:So are we in agreement that the math is now correct via the above posts?

You have to decide that. I provided calculations based on your provided requirements. Campbell Ritchie probably as well, but only him could confirm that.

Mona Stout wrote:I have the classes defined correctly?

Write down classes names separated by comma again, so we could see once again.

The SalesPerson class has to have two people for an Array/Array List comparison

Yes, you can put two SalesPerson objects to an array if it is a part of your requirements. If not, then not necessarily if you're going to have only 2 persons.

Mona Stout wrote:So I would have to label them SalesPerson1 and SalesPerson2, correct?

Don't use "label them" phrase. Use - "instance".

Mona Stout wrote:Then do a set() and get() for each one of them.
Does this apply for everything that I do for one I have to write for both or did I misunderstand that part in the book?

I don't know what you book says, but, in your current case - yes.
 
Campbell Ritchie
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote: . . .
The SalesPerson class has to have two people for an Array/Array List comparison
So I would have to label them SalesPerson1 and SalesPerson2,
. . .

Do you mean that there have to be two instances of sales person and they are put into a List<SalesPerson>? I hope you do. That would of course be inside an instance of a different class, sales force, sales department, company or whatever. Your variable names should start with s not S. If they are in a List you can get away without names, because they would be salespeople[i] or salespeople.get(i). If you have the option to use a List, do that in preference to an array. Remind yourself of the capabilities of Lists in the Java™ Tutorials. Remind yourself of how to compare objects also in the Java™ Tutorials.
In real life a company would appoint a sales person who can later resign, but implementing that sort of thing might simply make your app more complicated than it has to be.

Yes, but only after you have got tests like those I showed you earlier to work. You cannot do anything with the sales person/person class until you have verified that it works.
 
Mona Stout
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Write down classes names separated by comma again, so we could see once again.


The classes that I came up with were Person, Process.

Yes, you can put two SalesPerson objects to an array if it is a part of your requirements


The assignment requires that an Array/Array list be used to compare two individuals


Does this mean it could be SalesPerson1 since a variable can have pretty much any name?
 
Liutauras Vilda
Marshal
Posts: 8728
625
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote:The classes that I came up with were Person

Implement this class first. Test as Campbell Ritchie told you yesterday or before yesterday. Then you'll see yourself if Process is needed.

Mona Stout wrote:The assignment requires that an Array/Array list be used to compare two individuals

Do as CR mentioned 1 post above.

Mona Stout wrote:Does this mean it could be SalesPerson1 since a variable can have pretty much any name?

Yes. But it is no longer needed as you need to add them to Array or ArrayList. Check again CR post (1 above).
 
Campbell Ritchie
Marshal
Posts: 77957
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mona Stout wrote:. . .
The classes that I came up with were Person, Process.

Two reasons not to use Process.
  • 1: It is too vague to explain what is happening.
  • 2: More serious: there already is a Process class and calling a class Process can cause dangerous confusion in future.
  • . . .
    Does this mean it could be SalesPerson1 since a variable can have pretty much any name?

    Yes and no. In theory you can call a variable anything which is not the name of a class nor a keyword, but you want a name making its meaning clear. Actually you can call a variable by the name of a class, like here:-But things will go horribly wrong if you give that class a main method.
     
    Mona Stout
    Greenhorn
    Posts: 29
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    So when I get home tonight does this mean that you want me to start coding this? You keep saying to test this but before you told me to stop coding and write everything on paper so that is what I have done. I know that you told me to not worry about due dates so I'm trying not to, but it is coming down to the wire.
     
    Liutauras Vilda
    Marshal
    Posts: 8728
    625
    Mac OS X VI Editor BSD Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    So, if you got full understanding for yourself, then you should start coding.
  • you got class name which you need to implement
  • you got field names you need (name, surname, salary, target)
  • you got method names and understanding what these need to do
  • also you got understanding how to do calculations
  • So you should start as you know the way more than you knew in your very first post with actual code written in there.
     
    Campbell Ritchie
    Marshal
    Posts: 77957
    373
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I think now is the time to try turning it all into code. Once you have got everything worked out, you will probably find it turns into code quickly. As Liutauras says, you have got a lot of the information you need written down in earlier posts already.
     
    Bartender
    Posts: 10780
    71
    Hibernate Eclipse IDE Ubuntu
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Mona Stout wrote:So when I get home tonight does this mean that you want me to start coding this? You keep saying to test this but before you told me to stop coding and write everything on paper so that is what I have done. I know that you told me to not worry about due dates so I'm trying not to, but it is coming down to the wire.


    I have to admit to having only browsed the thread, but I'd say that the advice you're being given boils down to two points - both of which are extremely important; and very difficult to grasp when you're starting out:
    1. Stop Coding.
    2. When you are designing in Java - or indeed ANY Object-oriented language - WHAT is much more important than HOW.

    The problem is that Java is a bit of a "hybrid" language - it gives you lots of opportunities to simply code "do this...do that" logic, which unfortunately is NOT what you need to understand a problem.

    HIH

    Winston
     
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hey mom,
    This is just something that I think would help you..
    It's not 100% done(and very sloppy) but I think this will give you a little kick start, hopefully..
    Didn't get to the incentive or the commission pay or anything really math related.
    I just reread through the whole thread and found out about the incentive after I got this to work.
    It's not exactly what you need, but I hopes it's a good building block and hope you can understand it.


     
    Campbell Ritchie
    Marshal
    Posts: 77957
    373
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I see things have changed since I was at school; then my mother tried to help me with homework. Of course, in those days programming was some arcane art which very few people practised.

    That is only part of the solution; it needs a method to calculate the commission. It also needs a means for creating two (at least) sales people objects and putting them into a List, and that requires another class. Beware of your use of Scanner. Start by telling me what your book says Scanner#nextLine does. Then look at this post. Then work out what might go wrong. Nothing untoward will happen in your current code unless you try to create a second s person object, but then things can go horribly wrong.

    And welcome to the Ranch
     
    Campbell Ritchie
    Marshal
    Posts: 77957
    373
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Dylan Stout wrote: . . .

    For better to give the sales person class a proper toString method then you can simply write
    System.out.println(grab);
    What a strange name to use, grab.
     
    Liutauras Vilda
    Marshal
    Posts: 8728
    625
    Mac OS X VI Editor BSD Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Your constructor looks like:
    Note, that you can use keyword "this" which in presence would refer to your instance variable.
    So in this case you don't need to think about different names in method parameters list.

    Mona Stout wrote:// target for all sales persons is $120,000


    Target sales are the same for all sales persons and it is not meant to change. Same as incentive. Maybe there is better way to declare and initialize them?

    Remember how you have at the moment:
     
    Everybody's invited. Except this tiny ad:
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
    reply
      Bookmark Topic Watch Topic
    • New Topic