Ok so I had to develop a class in which I needed to count the number of times someone enters in a number from a selected group of numbers from 1 to 100. In this case we're talking about groups of 10. Since I'm not very good with arrays (it was advised I use an array of counters, but since my professor has yet to teach us do so, that wouldn't really work anyway). So I decided to get creative and do it this way (not finished yet, only worked up to 60 so far). The funny thing is, the first 3 groups work out perfectly, but after that it's almost like it won't read any input, any help would be appreciated in this matter, thanks ahead guys.
Code:
import java.util.Scanner;
public class TestingNew
{
public static void main (String[] args)
{
Scanner scan = new Scanner (System.in);
final int MAXNUMBER = 101;
int[] list = new int [MAXNUMBER];
System.out.println ("How many integers between 1 and 10 will you enter?");
int num = scan.nextInt();
System.out.println ("How many integers between 11 and 20 will you enter?");
int num1 = scan.nextInt();
System.out.println ("How many integers between 21 and 30 will you enter?");
int num2 = scan.nextInt();
System.out.println ("How many integers between 31 and 40 will you enter?");
int number = scan.nextInt();
System.out.println ("How many integers between 41 and 50 will you enter?");
int number1 = scan.nextInt();
System.out.println ("How many integers between 51 and 60 will you enter?");
int number2 = scan.nextInt();
System.out.print ("1 - 10 | ");
int index = 0;
while (index < num)
{
System.out.print ("*");
index++;
}
System.out.println(" ");
System.out.print ("11 - 20 | ");
for (int index1 = 0; index1 < num1; index1++)
{
System.out.print ("*");
}
System.out.println (" ");
System.out.print ("21 - 30 | ");
for (int index2 = 0; index2 < num2; index2++)
{
number = number;
System.out.print ("*");
}
System.out.println(" ");
System.out.print ("31 - 40 | ");
for (int i = 0; i < number; i++);
{
System.out.print ("*");
}
System.out.println(" ");
System.out.print ("41 - 50 | ");
for (int index3 = 0; index3 < number1; index3++);
{
System.out.print ("*");
}
System.out.println("");
System.out.print ("51 - 60 | ");
for (int index4 = 0; index4 < number2; index4++);
{
System.out.print ("*");
}
System.out.println("");
}
}
Comment