Java arrays print asterisks

Java arrays print asterisks … here is a solution to the problem.

Java arrays print asterisks

I know

it’s just a simple java array issue, but I don’t know how to do it. Here’s what I want to do:

Student score chart
John 3 ***
Mark 2 **
James 1*

I have an array like this in mind:

String[][] students = { { "John", "Mark", "James" }, { "3", "2", "1" } };

How to print a line chart without adding another set of variables to the array? I want it to only show an asterisk (*) based on the score.


Like this?

int gradeAsInt = Integer.parseInt (students [1][n]);
for (int i = 0; i < gradeAsInt; ++i) System.out.print ("*");

Related Problems and Solutions