So I am in a computer science class at my school and there is this one program that I can't seem to figure out! If anyone here would like to help, I really appreciate it! Could someone explain to me how to do the for loops? Well here's the objective:
Design and implement an application that reads a set of values in the range 1 to 100 from the user and then creates a chart showing how often the value appeared. The chart should look like the one shown here. It shows how many values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered.
1-10 *****
11-20 **
21-30 *******************
31-40
41-50 ***
51-60 ********
61-70 **
71-80 *****
81-90 *******
91-100 *********
Here's what I have so far:
import java.util.Scanner;
public class C6p4
{
public static void main (String[] args)
{
Scanner kb = new Scanner(System.in);
int[] count = new int[10];
int num;
if (num >= 1 && num <= 10)
count[0];
if (num >= 11 && num <= 20)
count[1];
if (num >= 21 && num <= 30)
count[2];
if (num >= 31 && num <= 40)
count[3];
if (num >= 41 && num <= 50)
count[4];
if (num >= 51 && num <= 60)
count[5];
if (num >= 61 && num <= 70)
count[6];
if (num >= 71 && num <= 80)
count[7];
if (num >= 81 && num <= 90)
count[8];
if (num >= 91 && num <= 100)
count[9];
}
for ( int i = 0; i < 9; i ++)
{
System.out.print(" ");
for ( int j = 1; j < count[i]; j ++)
{
System.out.print("*");
}
}
}
I'm using Eclipse and it says there's a syntax error with all the "count[ # ]; "
and my brackets. Anyway, someone please help this desperate lady