Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

java

Name: Anonymous 2007-04-02 21:47 ID:lENHJj++

i have to create a loop, in the loop i have to take the input values (from keyboard) and then output min/max and average of the values entered. I have no problem with the average, but the only way i can find how to figure the min/max is through a text file example, which doesnt help me when it has to be through keyboard. help pls
8)

Name: Anonymous 2007-04-03 2:29 ID:E9Q9j2ej

>>4
I assume he's just going to add them up, then divide by the total afterwards.

>>1 >>3
Dumbass, you don't need to store the values at all.

OP, define four variables: max, min, total, n. Read one line of input, set max=min=total={value} and n=1. Then start looping. Read a value; if it's greater then max, set max; if it's less than min, set min; then add it to total and n++.

When you reach the end of the input, output max, min, and total/n.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List