News and important info, general banter, and suggestions for 5punk
Moderator: Forum Moderators
-
deject
- Berk

- Posts: 10353
- Joined: December 7th, 2004, 17:02
- Location: Oklahoma City, OK, USA
-
Contact:
Post
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();
}
}
}
-
wyrd
- Polar Bear

- Posts: 275
- Joined: March 23rd, 2005, 0:21
- Location: in the navy...
-
Contact:
Post
by wyrd »
but why?
-
Dog Pants
- Site Moderator

- Posts: 21653
- Joined: April 29th, 2005, 13:39
- Location: Surrey, UK
-
Contact:
Post
by Dog Pants »
You left your real name on it. Now we can all perform Voodoo rituals on you.
-
spoodie
- Site Moderator

- Posts: 9246
- Joined: February 6th, 2005, 16:49
- Location: Essex, UK
Post
by spoodie »
oooo pretty letters

-
deject
- Berk

- Posts: 10353
- Joined: December 7th, 2004, 17:02
- Location: Oklahoma City, OK, USA
-
Contact:
Post
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...
-
Anhamgrimmar
- Ninja Pirate

- Posts: 1517
- Joined: July 17th, 2005, 13:29
- Location: Saaaarfampton
Post
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
-
deject
- Berk

- Posts: 10353
- Joined: December 7th, 2004, 17:02
- Location: Oklahoma City, OK, USA
-
Contact:
Post
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.
-
Joose
- Turret

- Posts: 8090
- Joined: October 13th, 2004, 14:13
- Location: The house of Un-Earthly horrors
Post
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.

-
Jinxx
- Optimus Prime

- Posts: 1000
- Joined: December 16th, 2004, 16:50
- Location: Wales.
-
Contact:
Post
by Jinxx »
Joose wrote:Code: Select all
Creates a graph of numbers inuppted by a file.
This is a code.
-
Hehulk
- KHAAAN!

- Posts: 4746
- Joined: April 18th, 2005, 15:36
- Location: Bummingham, England
-
Contact:
Post
by Hehulk »
Why has no-one said it?
Think I'll be having a wurd to dejects mum...
-
Nickface
- Ninja Pirate

- Posts: 1568
- Joined: November 15th, 2004, 13:13
- Location: Detroit, MI, United States
-
Contact:
Post
by Nickface »
-
mrbobbins
- Robotic Despot

- Posts: 4595
- Joined: October 14th, 2004, 21:35
- Location: Sitting in a tin can
-
Contact:
Post
by mrbobbins »
-
cashy
- Zombie

- Posts: 2024
- Joined: May 9th, 2005, 19:43
- Location: shropshire
Post
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...