Need Java help: System.out.println, System.out.print and System.out.format

I need three different columns displaying information as follows in the screenshot. They should contain different values for number of times cpu has been accessed.

Here is the code I have so far, which displays only one column:

public class JRoundRobin{ public static void main(String[] Me) { int N[] = new int[28]; int M[] = new int[28]; int P[] = new int[28]; int k; boolean IsItFilled; N[25] = 0; // cpu eaten M[25] = 0; // cpu eaten P[25] = 0; // cpu eaten N[24] = 50; // cpu time allotted M[24] = 50; // cpu time allotted P[24] = 50; // cpu time allotted N[26] = 0; // index filled M[26] = 0; // index filled P[26] = 0; // index filled N[27] = 0; // #times called M[27] = 0; // #times called P[27] = 0; // #times called N[23] = 100; // start number of smallest M[23] = 1000; // start number of smallest P[23] = 10000; // start number of smallest N[22] = 0; // start number of biggest M[22] = 0; // start number of biggest P[22] = 0; // start number of biggest N[20] = 0; // start number of sum M[20] = 0; // start number of sum P[20] = 0; // start number of sum for ( k = 0; k < 20; k++) { N[k] = 0; M[k] = 0; P[k] = 0; } IsItFilled = true; while (IsItFilled) { PopulateTheNArray(N); if (N[19] != 0 ) { IsItFilled = false; } } GetSumForN(N); GetAverageForN(N); GetBiggestForN(N); GetSmallestForN(N); GetCPUTimeAllotedForN(N); for ( k = 0; k < 28; k++) { System.out.println("\n\t\tArray: N[" + k + "] = " + N[k]); } //PopulateTheMArray(N); //PopulateThePArray(N); } // end of domain of public static void main // domain of the methods public static void PopulateTheNArray( int []Q) { long StartTime,EndTime; int k,IndexFilled,Holder; StartTime = 0; EndTime = 0; IndexFilled = 0; StartTime = System.currentTimeMillis(); for (k = 0; k < 20; k++) { if ( Q[k] == 0 ) { IndexFilled = k; k = 21; } } k = IndexFilled; while ( k < 20 ) { Holder = (int)(Math.random()*1000); if ( Holder > 9 && Holder < 100 && Holder % 2 == 0 ) { Q[k] = Holder; EndTime = System.currentTimeMillis(); k++; } if ( (int)(EndTime - StartTime) > Q[24] ) { k = 21; } } Q[27] +=1; } public static void GetSumForN( int []Q) { int k; for (k = 0; k < 20; k++) { Q[20] += Q[k]; } } public static void GetAverageForN(int []Q) { Q[21] = Q[20]/20; } public static void GetBiggestForN(int []Q) { int k; for ( k = 0; k < 20; k++) { if ( Q[k] > Q[22] ) Q[22] = Q[k]; } } public static void GetSmallestForN(int []Q) { int k; for ( k = 0; k < 20; k ++ ) { if ( Q[k] < Q[23] ) Q[23] = Q[k]; } } public static void GetCPUTimeAllotedForN(int []Q) { Q[24] = Q[27] * Q[24]; }}

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

"Error: Main method not found in class JRoundRobin, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application"

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

mccarlIT Business Systems Analyst / Software DeveloperCommented:

You've messed up something else in your code then. Post the (new) full code.

so_calAuthor Commented:

public class JRoundRobin{ public static void main(String[] Me, Object arg1){ } public static void main(String[] args) { int N[] = new int[28]; int M[] = new int[28]; int P[] = new int[28]; int k; boolean IsItFilled; N[25] = 0; // cpu eaten M[25] = 0; // cpu eaten P[25] = 0; // cpu eaten N[24] = 50; // cpu time allotted M[24] = 50; // cpu time allotted P[24] = 50; // cpu time allotted N[26] = 0; // index filled M[26] = 0; // index filled P[26] = 0; // index filled N[27] = 0; // #times called M[27] = 0; // #times called P[27] = 0; // #times called N[23] = 100; // start number of smallest M[23] = 1000; // start number of smallest P[23] = 10000; // start number of smallest N[22] = 0; // start number of biggest M[22] = 0; // start number of biggest P[22] = 0; // start number of biggest N[20] = 0; // start number of sum M[20] = 0; // start number of sum P[20] = 0; // start number of sum for ( k = 0; k < 20; k++) { N[k] = 0; M[k] = 0; P[k] = 0; } IsItFilled = true; while (IsItFilled) { PopulateTheNArray(N); if (N[19] != 0 ) { IsItFilled = false; } } GetSumForN(N); GetAverageForN(N); GetBiggestForN(N); GetSmallestForN(N); GetCPUTimeAllotedForN(N); for ( k = 0; k < 28; k++) { System.out.println("\n\t\tArray: N[" + k + "] = " + N[k]); System.out.format("%20s%20s%20s%n", "Array N", "Array M", "Array P"); for ( k = 0; k < 28; k++) { System.out.format("%20d%20d%20d%n", N[k], M[k], P[k]); } } //PopulateTheMArray(N); //PopulateThePArray(N); } // end of domain of public static void main // domain of the methods public static void PopulateTheNArray( int []Q) { long StartTime,EndTime; int k,IndexFilled,Holder; StartTime = 0; EndTime = 0; IndexFilled = 0; StartTime = System.currentTimeMillis(); for (k = 0; k < 20; k++) { if ( Q[k] == 0 ) { IndexFilled = k; k = 21; } } k = IndexFilled; while ( k < 20 ) { Holder = (int)(Math.random()*1000); if ( Holder > 9 && Holder < 100 && Holder % 2 == 0 ) { Q[k] = Holder; EndTime = System.currentTimeMillis(); k++; } if ( (int)(EndTime - StartTime) > Q[24] ) { k = 21; } } Q[27] +=1; } public static void GetSumForN( int []Q) { int k; for (k = 0; k < 20; k++) { Q[20] += Q[k]; } } public static void GetAverageForN(int []Q) { Q[21] = Q[20]/20; } public static void GetBiggestForN(int []Q) { int k; for ( k = 0; k < 20; k++) { if ( Q[k] > Q[22] ) Q[22] = Q[k]; } } public static void GetSmallestForN(int []Q) { int k; for ( k = 0; k < 20; k ++ ) { if ( Q[k] < Q[23] ) Q[23] = Q[k]; } } public static void GetCPUTimeAllotedForN(int []Q) { Q[24] = Q[27] * Q[24]; }}

mccarlIT Business Systems Analyst / Software DeveloperCommented:

First, can you clarify a couple of points for us just to set the context of your question...

Is this a homework/academic related question?

And, is the code that you have posted someone else's? And you are trying to either understand it, extend it or complete it?

I'm unable to get Array M and Array P to populate. Do I just copy the code I have for Array N and paste it somewhere? If so, where?

Firstly, if you look at the methods towards the bottom of the code, the ones the "Populate" or "GetXXXX", they all take an array as an argument so they don't necessarily have to operate on the N array. So I would take the N out of the names of those methods, eg.

PopulateTheNArray would become PopulateTheArray
GetSmallestForN would become GetSmallest or GetSmallestForArray

etc...

Now to answer your specific question, I can't really help too much just at the moment because from what you have told us so far, I have no idea what each of the N, M and P arrays need to be populated with, I have no idea what they mean. You would need to describe in more detail what you are trying to do.

so_calAuthor Commented:

E.g. The code you posted:
System.out.format ("\n total ,n[20] ?

is missing a close " and )

System.out.format ("\n total" ,n[20]) ;

Thank you for that.

so_calAuthor Commented:

Yes, this is a homework/academic question.

Most of is is the code the instructor has provided. Yes, I am trying to understand it, and extend it to look like the finished product. The problem is that I don't know how to get to the finished product.

Basically I have part of the code without any errors (RoundRobin.java), but more code needs to be added to make it more functional. So, Array M, and Array P are to generate random numbers, which they are currently not. The Arrays are just names.
Notice Array N = two digits, Array M = 3 digits, Array P = 4 digits. I also need the total, average, biggest, smallest, etc

The code from Array N could be reused to make Array M and P, but changing the M instead of N, and 1000 instead of 100, or something like that. Also the numbers are to be right-aligned.

mccarlIT Business Systems Analyst / Software DeveloperCommented:

Ok at this point, all I can say is that we are a long way off track from the original question and we would still have a very long way to go before you would be happy.

SO, all I can suggest at the moment is that if you are happy with the feedback provided in response to your initial question only, then I would ask you to resolve this question as you see fit. And then you can open a new question to get more help for the current issues. However I would suggest that you still need to provide much more information about what you are trying to do. Your statements above are still too vague to grasp what you want. Your comment of "or something like that" is never going to be precise enough to communicate too us what you need the code to do.

mccarlIT Business Systems Analyst / Software DeveloperCommented:

You're welcome!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for freeEdge Out The Competitionfor your dream job with proven skills and certifications.Get started todayStand Outas the employee with proven skills.Start learning today for freeMove Your Career Forwardwith certification training in the latest technologies.Start your trial today