Im having a bit of trouble with trying to print an array using printf, Im doing it through OOP. Im passing random salaries for 10 sales Reps.
Here is what I've got so far...
public void printArray()
{
for(int salesRep = 0; salesRep < salary.length; salesRep++)
{
System.out.printf("Sales Rep %d%n", "%4d Current Salary: %2.f", (salesRep + 1), salary[salesRep]);
}
}
This is the output I'm getting...
However I'm trying to get it to display like this...

Any help would be appreciated.


printf(String format, Object... args). But you have two format strings, and then 2 arguments, instead of 1 format string and 3 arguments.