Call
(317)643-0663
for consultation
Experience Programming
.
Home
Pricing
About
Contact
Java Example
Horizontal Histogram
.
Back to Examples
package edu.iuk.Histogram;
//imports
import java.util.Scanner;
public class Histogram {
public static void main(String[] args) {
//Jacob Morris
int num[] = new int[5];
int counter=0;
//ask for the numbers, and enter the numbers into the array
for(int var=0;var<5;var++){
Scanner number = new Scanner(System.in);
System.out.println(“Please enter a number: “);
num[var] = number.nextInt();
}
//to ensure the numbers stop after five numbers
while(counter <5){
//to output the number of stars
while(num[counter]>0){
System.out.print(“*”);
num[counter]= num[counter] -1;
}
System.out.print(“\n”);
counter++;
}
}
}
Back to Examples
Startup Discount
Small Business?
Contact us for an
Enormous
Discount!
Contact Us Today!