• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Java and netbean week 3 Salesperson Java™ Application Part II

 
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am struggling with the table portion for week three  


What have you tried?  Do you have a specific question?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this is what he is looking for can you give me some input on how to add it to my other code.


 
jeff cantrell
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or do you think that this would be good enough not to have to put week 2's with week 3's
 
Knute Snortum
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jeff cantrell wrote:Or do you think that this would be good enough not to have to put week 2's with week 3's


The instructions say

Modify the Week Two Java application


so I think you need both week two and three together.
 
Knute Snortum
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

can you give me some input on how to add it to my other code.


First I would rename any variables that do the same thing in the two programs but are declared as different names.  Then I would just start copying and pasting the code from one file to the other.
 
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jeff cantrell wrote:I did this for week two and this is what I came up with and it is correct for the assignment I am struggling with the table portion for week three which is what the assignment I ask questions about is added on to this.


jeff cantrell wrote:this was week 2's assignment question
...
The Java application should meet these technical requirements:
The application should have at least one class, in addition to the application's controlling class (a controlling class is where the main function resides).
There should be proper documentation in the source code.


One fundamental problem is that you think your Week 2 submission was correct but it actually isn't. I have often railed against the way students are taught these days and this is just another prime example of the kind of problems I see in the quality of instruction. It's all giving without proper guiding. You're (hopefully) given a lot of material to digest but you're not guided on the right ways to do things.

Here are the problems with your week II solution:

1. All your code is in the static main() method. This makes what you wrote more of a script, not a proper Java program.

2. You were required to "have at least one class in addition to the application's controlling class" which you do not have. Again, this is because all your code is jammed into one place: the main() method of what basically should be your "controlling class".

3. Because you failed to provide an additional class, I doubt you understand what the requirement aims to teach. I tried to explain what you needed to do in the previous replies that I posted. I realize that you probably looked at those long posts and your eyes glazed over but those are some of the things that can help you understand the goal of the requirement. I tried to give simple examples to hold your interest but the concepts are not trivial and you really need to study those examples and see how everything fits together. IMO, understanding what I tried to explain there would actually help you move forward.

4. I think #3 because you think you can just add on to what you did in week II to get a solution for week III. If you tried hard and long enough, you might succeed in producing the desired output but if you stay on the trajectory that you're on right now, the resulting code will still not meet the technical requirement and it will be a big mass of code that's hard to understand, otherwise known as a Big Ball of Mud.

I asked whether you were willing to throw away most of the code that you wrote before and basically start over with the pattern I gave you. It seems like you're not inclined to do that though, which is fine but a little disappointing. Good luck.
 
Knute Snortum
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are still a lot of problems with both your programs.
In CommissionCalculation1:
  • You declare a variable commission, but you don't use it in your calculation.

  • In AnnualSales:
  • Get rid of the line @SuppressWarnings("empty-statement")
  • You have commRate set to .5.  It should be .05 or use the variable commission.
  • You need to fill in the code in the for loop at the bottom.
  •  
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I'll give it one more shot.

    Here's a smaller example of how your program needs to be structured:


    This code will satisfy the requirement to "have at least one class in addition to the application's controlling class." The classes in the example have been named accordingly. That's the basic pattern you need to follow.
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Junilu Lacar wrote:

    jeff cantrell wrote:I did this for week two and this is what I came up with and it is correct for the assignment I am struggling with the table portion for week three which is what the assignment I ask questions about is added on to this.


    jeff cantrell wrote:this was week 2's assignment question
    ...
    The Java application should meet these technical requirements:
    The application should have at least one class, in addition to the application's controlling class (a controlling class is where the main function resides).
    There should be proper documentation in the source code.


    One fundamental problem is that you think your Week 2 submission was correct but it actually isn't. I have often railed against the way students are taught these days and this is just another prime example of the kind of problems I see in the quality of instruction. It's all giving without proper guiding. You're (hopefully) given a lot of material to digest but you're not guided on the right ways to do things.

    Here are the problems with your week II solution:

    1. All your code is in the static main() method. This makes what you wrote more of a script, not a proper Java program.

    2. You were required to "have at least one class in addition to the application's controlling class" which you do not have. Again, this is because all your code is jammed into one place: the main() method of what basically should be your "controlling class".

    3. Because you failed to provide an additional class, I doubt you understand what the requirement aims to teach. I tried to explain what you needed to do in the previous replies that I posted. I realize that you probably looked at those long posts and your eyes glazed over but those are some of the things that can help you understand the goal of the requirement. I tried to give simple examples to hold your interest but the concepts are not trivial and you really need to study those examples and see how everything fits together. IMO, understanding what I tried to explain there would actually help you move forward.

    4. I think #3 because you think you can just add on to what you did in week II to get a solution for week III. If you tried hard and long enough, you might succeed in producing the desired output but if you stay on the trajectory that you're on right now, the resulting code will still not meet the technical requirement and it will be a big mass of code that's hard to understand, otherwise known as a Big Ball of Mud.

    I asked whether you were willing to throw away most of the code that you wrote before and basically start over with the pattern I gave you. It seems like you're not inclined to do that though, which is fine but a little disappointing. Good luck.







    I am willing to do what ever it takes to get this done if I have help I am so new at writing all of this java it is very confusing to me and very hard I am not use to doing all of this programming without a book handy to me.  if you could please help me with getting it done I am willing to start fresh.  I have until monday to get it done but I have to turn it in to my group by friday which I can always have them do it later I can explain why.  thanks everyone for your then help
     
    Knute Snortum
    Sheriff
    Posts: 7126
    185
    Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Junilu Lacar wrote:I'll give it one more shot.

    Here's a smaller example of how your program needs to be structured:


    This code will satisfy the requirement to "have at least one class in addition to the application's controlling class." The classes in the example have been named accordingly. That's the basic pattern you need to follow.


    This code is a really good template for how you should structure your code.  Why don't you start there and show us what you get?
     
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    jeff cantrell wrote:I am willing to do what ever it takes to get this done if I have help


    That's good to hear.

    As I see it, the main thing that's confusing you is having all your code in main() instead of having multiple independent chunks of code that perform various and specific tasks. In order for us to help you and keep the discussion moving forward, it's important that you at least understand how that template code will allow you to break apart all the code that you currently have in main() and arrange them more logically.

    So, do you understand what you need to do with that code template? Do you see what roles the Controller and Additional classes will each play?
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I barely got what I had I really don't understand any of it I see that it has to be in different classes which puts them on different pages when you are using netbean.  So lets start with the code that I had from week 2 and fix it if we can salvage it to make sure that it is correct even though week two is done.  I want to be able to combine week threes with week twos I think I have week threes now If you can take a look at what I have for week three I had a little extra help on three.  Now I am having trouble combining it with two.
    i will post the two weeks on the next couple of threads so you can tell me what is wrong with them
     
    Marshal
    Posts: 80634
    471
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    jeff cantrell wrote:. . .  I am willing to start fresh.  . . . turn it in to my group by friday . . .

    Start by writing down in your own words what you are going to do. How are you going to calculate the pay for a sales rep who sells $xyz? Start by doing that, and then get into simpler and simpler words, so even I can understand it. Do not use any words gleaned from programming, Java®, computers, etc. And make sure you have no electronic equipment running (well, maybe music is allowed). You are using pen pencil and eraser. The eraser is probably the most important tool
     
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The best way to salvage what you have written already is to put it in the junk yard and cannibalize it for parts, not to bring into the shop and try to overhaul it. You should start with the suggested template and try to pick out the parts of what you wrote before to use within the template.  Do you know what I mean?
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This is week 2s assignment that I did my teacher said that it was ok for the assignment I seen some post on here that said I needed to change some things but I need some help understanding what to change.  in order to get my week 3 assignments to work with this assignment.

     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    here is the code for my week 3 assignment.  I have a driver class and a salesperson class that are going to be separate code classes from my understanding if i'm correct.  They each have their own page for their class.  away from the commissioncalculation1 and the driver and salesperson classes will make the table show up but then the commissioncalculation portion will not be a part of that as well.


    this is the Driver calculator


    then this is the Salesperson class

     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I really think it needs to be these three codes added together some how and I dont know how to add them together.









     
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This last batch of code actually looks a little better. Your DriverCalculator and SalesPerson classes almost follow the suggested pattern. Why do you think you need to add in the CommissionCalculator1?
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I thought I had to combine the two.  in order for them to work but i may have read this wrong I may just need the two classes now.

    Modify the Week Two Java application using NetBeans IDE to meet these additional and changed business requirements:
    The company has recently changed its total annual compensation policy to improve sales.
    A salesperson will continue to earn a fixed salary of  $50,000. The current sales target for every salesperson is $110,000.
    The sales incentive will only start when 80% of the sales target is met. The current commission is 5 percent of total sales.
    If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.5.
    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.
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    there was one portion i had to change in my code due to it having 100000 instead of the actual 50000 for the fixed salary

    }
            fixedSalary=50000;// set fixed salary is 50000$
           
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    its one line 35
     
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    BTW, I'm pretty sure NetBeans will allow you to have one public class and any number of non-public classes together in the same "page" as you call it.  The formal name is "compilation unit," more commonly known as a  *.java source file.

    You should be able to use this code in NetBeans exactly as it is shown above.  What I'm getting at is that if you remove the public keyword from your DriverCalculator and SalesPerson classes, you can put them in the same "page" in NetBeans as your CommissionCalculator1 class.
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    right I have seen that work in netbean with the classes.  I will try it.  But am I right with having to have them all work together with week two.
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ok if I was to do that where would I put them...
     
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    jeff cantrell wrote:right I have seen that work in netbean with the classes.  I will try it.  But am I right with having to have them all work together with week two.


    I don't believe you correctly understood what is being asked of you.

    The requirements say:
    A salesperson will continue to earn a fixed salary of $50,000

    That change you made, fixedSalary = 100000, is direct contradiction to that requirement.

    The requirements say:
    Sample Table: Assuming a total annual sales of $100,000, the table would look like this:

    Look carefully at your code for SalesPerson for something that represents the annual sales.
     
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    jeff cantrell wrote:Ok if I was to do that where would I put them...


    Yeah, well, that's kind of your job to figure out now, isn't it?

    Not to be mean or anything but you have to put your thinking cap on and make a little effort.
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    this is how I set it up and it only runs how it did last week only the commissioncalculation portions will run the rest of the classes will not run with the program.


     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    this is what comes out when I run it no table or anything like it should..


    The Salesperson earns a fixed monthly salary of $4166.666666666667.
    The Salesperson earns a fixed annual salary of $50000.0.
    The Salesperson will receive a commission of 5%.
    Enter annual sales: 125000
    The annual sales of the salesperson is $6250.0 using a 5% commission.
    The total annual compensation of the salesperson is: $56250.0.
    BUILD SUCCESSFUL (total time: 3 seconds)
     
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Jeff, you keep getting lost in the weeds of all that code you have written.  Programming is about systematically attacking a problem. By systematic, that means little by little, piece by piece, one line of code at a time.  This is my final hint to you, at which point, I'll have to step away and maybe someone else can try to guide you. To use a housebuilding analogy, you start by laying out a foundation, then you do framing, then put up the trusses, then put up the walls, etc. You don't try to build the house all at once because that would just be big confusing mess..

    It's best to start with an outline that gives you a good view of the lay of the land. You need to start with the template. Here's how I would start framing this out.

    I suggested that you put all that code in the junkyard and just mine it for parts.  Try to figure out how to take bits and pieces of the code that you're struggling with and organize them within the framework I show above. Good luck.
     
    jeff cantrell
    Ranch Hand
    Posts: 38
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Junilu Lacar wrote:

    jeff cantrell wrote:right I have seen that work in netbean with the classes.  I will try it.  But am I right with having to have them all work together with week two.


    I don't believe you correctly understood what is being asked of you.

    The requirements say:
    A salesperson will continue to earn a fixed salary of $50,000

    That change you made, fixedSalary = 100000, is direct contradiction to that requirement.

    The requirements say:
    Sample Table: Assuming a total annual sales of $100,000, the table would look like this:

    Look carefully at your code for SalesPerson for something that represents the annual sales.



    So you are saying that I changed that wrong thing and it should stay at the 100,000.  Also I understand that it is my job to find how to connect them dont I use some kind of command to call them to work or something like that.
     
    Junilu Lacar
    Sheriff
    Posts: 17734
    302
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    jeff cantrell wrote:So you are saying that I changed that wrong thing and it should stay at the 100,000.


    No, that's not what I said at all.

    When you read "continue to earn a fixed salary of $50,000" do you really take that to mean "change the fixed salary to $100,000"?  C'mon, man.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic