yeah i have just noticed that its doing 6 times, because its counting 0,
also another thing that i have noticed is that when

int counter = 0;

and then

while(counter <= 19)

it counts 20 students which is fine...
but after i put input (10 10 20 20 30 30 40 40 50 50 60 60 70 70 80 80 90 90 100 100)
this is the histogram i'm getting
0-29 *** <- 1 * is missing here... becasue 10 10 20 20 fall into one group but it prints only 3 * instead of 4 ?
30-39 **
40-69 ******
70-100 ********

Not sure why that would be, there are a couple of ways you could be getting that. Try entering them in a different order, say

100 10 20 20 30 30 40 40 50 50 60 60 70 70 80 80 90 90 100 10

And see if that changes anything. (this is to see if your first input is getting counted)

nope my first input is not counted

Okay, here's why:

Scanner input = new Scanner(System.in);
        System.out.println("enter student marks");

        [U]marks = input.nextInt();[/U]
        while( counter <= 20)
        {
        marks = input.nextInt();

        if(marks <=29){
...

You're taking and input there and just eating it.

emm i have removed the first statement but still it eats one input

Well, sounds like you've got a bit of debugging to do.

ee how do i do it ;) ?

Big question.
Briefly, you need to examine the code you've written and figure out what it's doing and where it's deviating from what you want it to do. It's a matter of understanding the code you've written. Often that means examining each line and thinking about how that changes the state of the data. Another useful trick is to start at the end and work back. You have the output. What values are used to produce that output? How did they get there - what was the last instruction that set those values? That instruction took some data - what data did it use, and how did it get that way?

Look at the topic from a few days ago on "getting unstuck" and see if anything there helps.

Anyway, this is a new question - mark this topic as solved, try to find this bug for yourself, and post a new topic if you find you're really stuck.

ok i'll have a look at the other topic later on, i will mark this topic as solved soon, i have few little things to do, so i'll just wait till i get them done, just in case so when i get stock i wont have to make new topic :), and i'll just post here... if everything will be fine with the rest i will mark this topic as solved :). and ofc. award points for all useful answers :)

and as i though i have found a problem again ...
i managed to display the number of people failing, and number of people passing... as also the average mark... but i can not get it to display the lowest and the biggest mark achieved this is the code i came up with

biggest = b;
        for(b=0;b<marks;b++)
        {
            if(biggest < marks)
                {
                    biggest = b;
                }
        }//end for loop/biggest no.
        lowest = l;
        for(l=0;l>marks;l++)
        {
            if(lowest > marks)
                {
                    lowest = l;
                }
        }//end for loop/lowest no.

Since you are not storing the data entered by the user, you cannot do this after the fact in a loop. You have to do it as you are reading in the data. Initialize highest to something low, like -1, and lowest to something high, like 101. Then when you read in a mark, if it is higher than highest, set highest to that mark. Similarly, if it is lower than lowest, set lowest to that mark.

for(b=0;b<marks;b++)
        {
            if(biggest < marks)
                {
                    biggest = b;
                }
        }

Step through what this does.

First iteration, b is set to 0, which is less than marks (presumably - what is marks at this point?) so then what happens? What value does biggest take?

so when first iteration is set to 0 the last input number i enter is compared to the 0, so the biggest take the last value entered ?
since i dont have all the values stored already i can not do comparing in a loop ?.

so when first iteration is set to 0 the last input number i enter is compared to the 0, so the biggest take the last value entered

if(biggest < marks)

What does this mean?

the value of bigger is less than marks oO
so it should be the other way around

if(biggest > marks);

No, leave it - you have to understand what you wrote before you go changing it, or you'll get all kinds of confused.

So what does this do?

if(biggest < marks)
                {
                    biggest = b;
                }

well if the value of biggest is less than marks so the condition is true, and then it goes to the next statement, and saves the biggest to b. but since i did not tell it what is the new biggest it wont save it ? the code know that the condition was met, but it doesnt know what is the new biggest. or it will ?

Other way around - it puts the value of "b" into "biggest"
Since "b" is 0, biggest is now 0.
Nxxt time, what happens?

well if now biggest is 0 it should compare to the next mark i enter, if the marks are greater then 0 it will execute the code below, but it will still sign the value of 0 into the biggest ?

The next time through, the value of b is 1 (remember, we're in a for loop) and biggest is still 0. I don't know what marks is worth, but I'm assuming it's over 0, so biggest is assigned the value of b, which is 1.

And likewise the next time through, b is 2 (goes up by one each time) and biggest is 1 (that's what it was assigned to on the previous round), and so if biggest is still less than marks, biggest is once again assigned the value of b, which is 2.

And this will go on. Where will it stop, and what will be the value of b when it does stop?

sorry been away for while.
well the loop will continue until biggest is greater then marks.? and the value of b will depend on the value of marks entered

ok i have fixed my problem :). the logic was fine, just what i have done is a have put this code outside my loop, and that was the reason why i was always getting biggest/lowest as the same number which was entered last!. now i can close the thread :)
this is what i came up with

if(biggest < marks){
            biggest=marks;
        }
        if(lowest > marks){
            lowest=marks;
        }

and i have put this inside the while loop, and it works :)
thank you for all help :)

I am also doing this, but i am stuk and need some help..
my code keeps given me 20 * for each catrgory.
how do i fix this?

could you post your code?

the output to my program is displayed like this

0-29
*
*
*

30-39
*
*
*
*
....

but i want it to be displayed like this:

0-29 ***
30-39 ****
...

how o i do that?

Where it says "println", put a "print"
Then put an empty println where you want a line break. ( System.out.println(); )

And start a new thread if you have a new question, dammit.

jon.kiparsky is right, println (short for print line) prints what you want in a new line. I never use print for some reason, instead i construct a string to println

String s = "";
for (int i = 0 ; i < 10 ; i++)
{
   s += ""+i;
}
println(s);

//is the same as

for (int i = 0 ; i < 10 ; i++)
{
   print(i);
}

will print out 01234567789 wheras

for (int i = 0 ; i < 10 ; i++)
{
   println(i);
}

will print out
0
1
2
...

thanks, how do i display the histogram vertically, without using arrays.
where the stars * in the catergory (0-29,30-39,40-69...) goes downwards not across the screen:

Like I said:

And start a new thread if you have a new question, dammit.

You start by making a new thread in which to ask your question.

Seriously, if you're not reading the answers you're getting, it'd be a waste of time trying to answer your questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.