Results 1 to 2 of 2
  1. #1
    rhym1n is offline Member
    Join Date
    Feb 2013
    Rep Power

    Default Array or ArrayList?

    First of all, this program is going to do the following:

    • Allow input of two salesperson's names AND input of their yearly sales
    • Calculate how much each salesperson earns each year by adding their yearly salary and commission from sales
    • Compare the two salesperson's yearly compensation (salary AND commission) and display the name of the salesperson that earned the higher amount
    • Calculate the difference between the 2 earnings and display that value as well

    Questions (I know how to perform the calculations and how to display the results, but I am confused about a couple things):

    1) This would use an array and not arraylist, correct? (I think because we know only 2 salespersons are entering information, it would be an array)

    2) I'm not quite sure how to combine user input with arrays, could somebody show a simple example?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Array or ArrayList?

    I would recommend writing a SalesPerson class which has their pertinent information (including their sales). Then allocate an ArrayList of type SalesPerson. In general, I would avoid arrays in Java.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Adding an array to an arraylist
    By drakeramoray in forum New To Java
    Replies: 5
    Last Post: 01-07-2013, 09:53 PM
  2. Array vs ArrayList
    By Lund01 in forum New To Java
    Replies: 5
    Last Post: 10-14-2010, 10:41 AM
  3. 2D array of ArrayList (technically a 3D array)
    By Lil_Aziz1 in forum New To Java
    Replies: 3
    Last Post: 05-15-2010, 08:11 PM
  4. Array and arraylist
    By MIA6 in forum New To Java
    Replies: 3
    Last Post: 11-29-2009, 02:22 AM
  5. Array to ArrayList
    By javaplus in forum New To Java
    Replies: 2
    Last Post: 11-12-2007, 12:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts