I am tasked with generating a 100 byte values and dispaly a number of "*"'s as an histogram showing the amount of times that a certain number was generated. I am having a hard time hard coding it to 99 and printing exactly what is asked. I am supposed to have something that looks like this: 0 |******* 1 |********* 2 |*************** 3 |******* 4 |****************** 5 |******* 6 |**************** 7 |***** 8 |**** 9 |************
This is what I have got.
import java.util.Scanner;
public class Display{
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("ENTER A DIGIT: ");
int input = keyboard.nextInt();
for(int i=0; i<input; i++) {
for(int j=0; j<input; j++) {
System.out.print("*");
}
System.out.println();
}
System.out.println();
}
Help would be greatly appreciated. Thanks !
Aucun commentaire:
Enregistrer un commentaire