Skip to content

Instantly share code, notes, and snippets.

@SniperProSerria117
Created October 30, 2014 13:11
Show Gist options
  • Save SniperProSerria117/637ce24472a29bf891cb to your computer and use it in GitHub Desktop.
Save SniperProSerria117/637ce24472a29bf891cb to your computer and use it in GitHub Desktop.
package barchart;
import java.util.Scanner;
public class BarChart {
public static void main(String[] args)
{
// declare a double array
double[] store = new double[5];
Scanner scan = new Scanner(System.in);
//declare a for loop
for(int i = 0; i < 5; i++)
{
System.out.printf("Enter today's sales for store %d: ", i + 1);
store[i] = scan.nextDouble();
}
System.out.println("SALES BAR CHART");
// declare a for loop
for(int i = 0; i < 5; i++)
{
System.out.printf("Store %d: ", i + 1);
//Nested for loop
for(int c = 0; c < store[i]/100; c++)
System.out.print("*");
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment