Hello everyone, I am AP COMPSCI A for my school and I trouble with this program. In the program you have to enter numbers from 1-100. And print a chart of how many numbers were between 1-10, 11-20 and so on. Like this:
1 - 10 |*
11- 20 |****
22- 30 |**
etc,
but for some reason my code doesn't work
/**
* @(#)NumChart.java
*
* NumChart application
*
* @author
* @version 1.00 2008/12/26
*/
import java.util.Scanner;
public class NumChart {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
int[] num= new int[15];
for(int i =0; i>15;i++)
{
System.out.print("Enter a number between 1-100: ");
num[i]= scan.nextInt();
while(i<1||i>100)
{
System.out.print("1-100 only please, Enter again: ");
num[i]= scan.nextInt();
}
}
int[] star= new int[10];
for(int j=0;j>10;j++)
star[j]=0;
for(int p=0;p<15;p++)
{
if(num[p]>=1&&num[p]<=10)
star[0]++;
else if(num[p]>=11&&num[p]<=20)
star[1]++;
else if(num[p]>=21&&num[p]<=30)
star[2]++;
else if(num[p]>=31&&num[p]<=40)
star[3]++;
else if(num[p]>=41&&num[p]<=50)
star[4]++;
else if(num[p]>=51&&num[p]<=60)
star[5]++;
else if(num[p]>=61&&num[p]<=70)
star[6]++;
else if(num[p]>=71&&num[p]<=80)
star[7]++;
else if(num[p]>=81&&num[p]<=90)
star[8]++;
else if(num[p]>=91&&num[p]<=100)
star[9]++;
}
System.out.print("1 - 10 | ");
for(int s=0;s<star[0];s++)
{
System.out.print('*');
}
}
}