Skip to content

Instantly share code, notes, and snippets.

@zachlatta
Created September 24, 2012 02:06
Show Gist options
  • Save zachlatta/3773825 to your computer and use it in GitHub Desktop.
Save zachlatta/3773825 to your computer and use it in GitHub Desktop.
Bar Chart
import java.util.Scanner;
public class BarChart {
public static void main(String[] args)
{
double[] store = new double[5];
Scanner userInput = new Scanner(System.in);
for(int i = 0; i < 5; i++)
{
System.out.printf("Enter today\'s sales for store %d: ", i + 1);
store[i] = userInput.nextDouble();
}
System.out.println("\nSALES BAR CHART");
for(int i = 0; i < 5; i++)
{
System.out.printf("Store %d: ", i + 1);
for(int c = 0; c < store[i]; c++)
System.out.print("*");
System.out.println();
}
userInput.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment