Page 1 of 1
yay for java
Posted: November 7th, 2005, 22:18
by deject
Code: Select all
import java.util.Scanner;
import java.io.*;
public class Histogram {
/**
* Description - Creates a graph of numbers inuppted by a file.
* @author Joshua Krell
* @date 11/07/2005
*/
final static int MAX_VALUE = 200;
public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub
Scanner file = new Scanner (new File("histogram.inp"));
int[] array = new int[10];
int count = 0;
int index, number;
while (file.hasNext() && count < MAX_VALUE)
{
count++;
number = file.nextInt();
index = (number - 1) / 10;
array[index]++;
}
int a;
String[] string = new String[10];
string[0] = "1 - 10 : " + array[0] + "\t|" + " ";
string[1] = "11 - 20 : " + array[1] + "\t|" + " ";
string[2] = "21 - 30 : " + array[2] + "\t|" + " ";
string[3] = "31 - 40 : " + array[3] + "\t|" + " ";
string[4] = "41 - 50 : " + array[4] + "\t|" + " ";
string[5] = "51 - 60 : " + array[5] + "\t|" + " ";
string[6] = "61 - 70 : " + array[6] + "\t|" + " ";
string[7] = "71 - 80 : " + array[7] + "\t|" + " ";
string[8] = "81 - 90 : " + array[8] + "\t|" + " ";
string[9] = "91 - 100 : " + array[9] + "\t|" + " ";
for (int x = 0; x < 10; x++)
{
a = array[x];
System.out.print(string[x]);
for (int y = 0; y < a; y++)
{
System.out.print("*");
}
System.out.println();
}
}
}
Posted: November 7th, 2005, 22:20
by wyrd
but why?
Posted: November 7th, 2005, 22:21
by Dog Pants
You left your real name on it. Now we can all perform Voodoo rituals on you.
Posted: November 7th, 2005, 22:21
by spoodie
oooo pretty letters

Posted: November 7th, 2005, 22:25
by deject
wyrd wrote:but why?
because it was assigned.
Dog Pants wrote:You left your real name on it. Now we can all perform Voodoo rituals on you.
http://www.acidplanet.com/deject
also, I'm curious as to why no one has asked what it does...
Posted: November 7th, 2005, 22:28
by spoodie
deject wrote:also, I'm curious as to why no one has asked what it does...
do we have to?
oh noes:
http://deject.stumbleupon.com/about/
Posted: November 7th, 2005, 22:29
by Anhamgrimmar
deject wrote:wyrd wrote:but why?
because it was assigned.
Dog Pants wrote:You left your real name on it. Now we can all perform Voodoo rituals on you.
http://www.acidplanet.com/deject
also, I'm curious as to why no one has asked what it does...
so whatdoes it do?
also:buh?the words? they are strange!
my total knowledge of programing is:
10 PRINT "you're AL GHEY!"
20 GOTO 10
Posted: November 7th, 2005, 22:33
by deject
well it takes a bunch of numbers from a file called "histogram.inp" and makes something like this:
Code: Select all
1 - 10 : 12 | ************
11 - 20 : 11 | ***********
21 - 30 : 15 | ***************
31 - 40 : 16 | ****************
41 - 50 : 5 | *****
51 - 60 : 3 | ***
61 - 70 : 6 | ******
71 - 80 : 4 | ****
81 - 90 : 12 | ************
91 - 100 : 4 | ****
where there's 12 numbers in the file from 1-10, 11 from 11-20, 15 from 21-30, etc. etc. etc.
the exact number of *'s depend on the numbers themselves.
Posted: November 7th, 2005, 23:50
by Joose
deject wrote:
also, I'm curious as to why no one has asked what it does...
Code: Select all
Creates a graph of numbers inuppted by a file.

Posted: November 8th, 2005, 2:10
by Jinxx
Joose wrote:Code: Select all
Creates a graph of numbers inuppted by a file.
This is a code.
Posted: November 8th, 2005, 2:35
by Hehulk
Why has no-one said it?
Think I'll be having a wurd to dejects mum...
Posted: November 8th, 2005, 4:04
by Nickface
Posted: November 8th, 2005, 9:57
by Woo Elephant Yeah
Posted: November 8th, 2005, 11:05
by mrbobbins
Posted: November 8th, 2005, 18:20
by cashy
deject wrote:well it takes a bunch of numbers from a file called "histogram.inp" and makes something like this:
Code: Select all
1 - 10 : 12 | ************
11 - 20 : 11 | ***********
21 - 30 : 15 | ***************
31 - 40 : 16 | ****************
41 - 50 : 5 | *****
51 - 60 : 3 | ***
61 - 70 : 6 | ******
71 - 80 : 4 | ****
81 - 90 : 12 | ************
91 - 100 : 4 | ****
where there's 12 numbers in the file from 1-10, 11 from 11-20, 15 from 21-30, etc. etc. etc.
the exact number of *'s depend on the numbers themselves.
oh... one of THOSE...