• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Payroll java project

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am working on a Payroll project (Payroll.java and PayrollApp.java) and have almost everything except for two things:
1) Once all employees are entered, the user is prompted to enter an iD number, then if found delete if from the arraylist all of the payrolls are stored in. (Lines 115-125 of PayrollApp)
2) When displaying the arraylist, it displays the amount of times the length is (For example, if containing two payroll objects, it will display twice. And three times if length is 3) How can i get it to display only once? (without brackets and commas preferably) (Lines 100-105; 198-203 of PayrollApp)
Thank you to anyone that helps!
Here's my code: (I am not sure if you needed it all of just the lines I mentioned previously so I included everything)

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alex Breault wrote:Hello, I am working on a Payroll project (Payroll.java and PayrollApp.java) and have almost everything except for two things:
1) Once all employees are entered, the user is prompted to enter an iD number, then if found delete if from the arraylist all of the payrolls are stored in. (Lines 115-125 of PayrollApp)
2) When displaying the arraylist, it displays the amount of times the length is (For example, if containing two payroll objects, it will display twice. And three times if length is 3) How can i get it to display only once? (without brackets and commas preferably) (Lines 100-105; 198-203 of PayrollApp)



Point 1: you currently have Map<Integer, Payroll>. If you need to delete the employee ID (the Integer) and "all" its payroll why not use Map<Integer, List<Payroll>>

Point 2: Looping a list and showing its content one by one is normal behavior. Why do you need to show only one? If indeed only one, which payroll to show, latest one?
 
Marshal
Posts: 79234
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried this?
if (myMap.containsKey("123456")) ...
Your main method is much much too long. The ideal length for a main method is one statement; you have all sorts of things in there which should be separate methods.
Never use == false or == true.
If you need to test whether a boolean is false use !b.
 
Alex Breault
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the displaying of the Arraylist, I need the entire list to be displayed only once whenever I display it, without the brackets and commas.
 
reply
    Bookmark Topic Watch Topic
  • New Topic