jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Output of names and sales not formatted properly. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Output of names and sales not formatted properly." Watch "Output of names and sales not formatted properly." New topic
Author

Output of names and sales not formatted properly.

Edward Strife
Greenhorn

Joined: Mar 15, 2012
Posts: 14
Hello,

I have completed all the required calculations however I am a bit stuck as how to format them for proper output. Since my loops are contained in their own method I cannot iterate through them one by one. The output should resemble:

John Doe 23% 13%
Jane Doe 32% 47%

However my output resembles:

John Doe
Jane Doe
.............23%
.............32%
...................13%
...................47%

(Spaces replace the periods shown in this example)

Any help would be greatly appreciated.

John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
You have not shown SalesPerson or the SortedListOfSalesperson class.

Anyways, instead of having three print methods, you can have only one print() method. Here iterate the list and compute sales and expenses for each SalesPerson.

So in your final print statement have like

And make your print() method void - you have got three print methods returning values that is not used.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Output of names and sales not formatted properly.
 
Similar Threads
Creating Objects without the "New" Keyword
Trying to print contents of object filled array list.
Unable to add object to array.
ArrayList selection Sort
Wrong output from salesReport, array not filling properly.