11-10-2012, 06:02 PM
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
11-11-2012, 06:25 AM
Now, back vaguely towards actual programming:
Can someone who knows some java help me with something. For a program I'm working on I need a method which puts the frequency of each character in the alphabet as a separate entry into an array (or as parts of the internet have suggested when I googled it, a hashmap, which I don't have a clue how to use). The program overall will put this data into a .csv file with a user specified name (which I've already got working). Basically, I have no idea what functions will help me, so can't even write a psuedocode version. When I looked it up, I found some examples, but don't like using other people's code unless I know what each line does and why, which is why I'm asking for help: I'd like to be told generally what I'll need to do, and which functions I'll need, and why, then try and make it myself from that information.
Can someone who knows some java help me with something. For a program I'm working on I need a method which puts the frequency of each character in the alphabet as a separate entry into an array (or as parts of the internet have suggested when I googled it, a hashmap, which I don't have a clue how to use). The program overall will put this data into a .csv file with a user specified name (which I've already got working). Basically, I have no idea what functions will help me, so can't even write a psuedocode version. When I looked it up, I found some examples, but don't like using other people's code unless I know what each line does and why, which is why I'm asking for help: I'd like to be told generally what I'll need to do, and which functions I'll need, and why, then try and make it myself from that information.
11-12-2012, 01:39 AM
Seeing as LordVador is making so may new threads, it looks like I'll have to...
*Bump*
*Bump*
11-12-2012, 07:45 AM
Why don't you just make the method yourself?
11-12-2012, 10:36 AM
I see you skim read what I wrote. The reason I don't write the code is that I have no idea what I'm doing. If I did, I could.
11-12-2012, 10:58 AM
I keep thinking that there must be something that I'm missing because that seems pretty easy.
So you want an array with 52 elements for each alphabetical character (upper and lower) with each element holding the number of times that character appears in the file correct?
Just make a for loop that runs 52 times and increments to the next letter each time. Then within that for loop have another for loop that goes through every character, checks to see if it matches the currently set character using an if statement, and if it does += 1 to the counter, then when it's done write the counter to the current array element. The outer loop should then pop to the next letter and the next array element.
Quote:I need a method which puts the frequency of each character in the alphabet as a separate entry into an array
So you want an array with 52 elements for each alphabetical character (upper and lower) with each element holding the number of times that character appears in the file correct?
Just make a for loop that runs 52 times and increments to the next letter each time. Then within that for loop have another for loop that goes through every character, checks to see if it matches the currently set character using an if statement, and if it does += 1 to the counter, then when it's done write the counter to the current array element. The outer loop should then pop to the next letter and the next array element.
11-12-2012, 11:07 AM
(11-09-2012, 04:10 PM)NaturalViolence Wrote: [ -> ]This is not true. If you are good, many places do not care if you got a degree in something unrelated or never even attended university.Quote:Ye, reason why you shouldn't rely on classes and start teaching stuff yourself lol...Quote:Most of my programming knowledge came from the internet when I studied stuff myself.
Well obviously. But to do anything with that knowledge career wise you need a degree. And to get that degree you're going to need to take these classes. And if you take these classes you're going to have to put up with the idiots in those classes. Therefore it's a common issue regardless of how much or little you learn about programming outside of class.
11-12-2012, 11:16 AM
(11-11-2012, 06:25 AM)AnyOldName3 Wrote: [ -> ]Now, back vaguely towards actual programming:in high level languages, hashmaps typically work such that you have pairs of values, called a "key", and a "value". The key is used as if it is an index into the hashmap.
Can someone who knows some java help me with something. For a program I'm working on I need a method which puts the frequency of each character in the alphabet as a separate entry into an array (or as parts of the internet have suggested when I googled it, a hashmap, which I don't have a clue how to use). The program overall will put this data into a .csv file with a user specified name (which I've already got working). Basically, I have no idea what functions will help me, so can't even write a psuedocode version. When I looked it up, I found some examples, but don't like using other people's code unless I know what each line does and why, which is why I'm asking for help: I'd like to be told generally what I'll need to do, and which functions I'll need, and why, then try and make it myself from that information.
Consider a normal array where you might do something like this:
Code:
alphabet[0] == "a"Code:
alphabet_indices["a"] == 0you can use this to easily do something like:
Code:
for character in input_string:
hitcounts[character] = hitcounts[character] + 1note i'm not using java, but you should get the idea.
11-12-2012, 11:20 AM
Actually I only need to search for uppercase characters, so would only need 26 elements.
The problems are as follows:
a) The internet has told me to use a hashmap instead of an array. I have no clue what the difference is, and no clue how to implement one.
b) I don't know exactly how to do the comparing a specific location in a string to another string. I only learned this afternoon how to compare the whole of a string to another string @(as stringName != "y" apparently always evaluates to true, even when the string is "y").
c) The example code I can find doesn't do this exactly how you say. There's a faster way to do it (there may be a library function that gives the total count of a character in a string, but the code I've seen was poorly formatted, so I struggled reading it).
The problems are as follows:
a) The internet has told me to use a hashmap instead of an array. I have no clue what the difference is, and no clue how to implement one.
b) I don't know exactly how to do the comparing a specific location in a string to another string. I only learned this afternoon how to compare the whole of a string to another string @(as stringName != "y" apparently always evaluates to true, even when the string is "y").
c) The example code I can find doesn't do this exactly how you say. There's a faster way to do it (there may be a library function that gives the total count of a character in a string, but the code I've seen was poorly formatted, so I struggled reading it).
11-12-2012, 11:20 AM
Quote:This is not true. If you are good, many places do not care if you got a degree in something unrelated or never even attended university.
Well it certainly increases your chances, a lot.
Quote:Actually I only need to search for uppercase characters, so would only need 26 elements.
The problems are as follows:
a) The internet has told me to use a hashmap instead of an array. I have no clue what the difference is, and no clue how to implement one.
b) I don't know exactly how to do the comparing a specific location in a string to another string. I only learned this afternoon how to compare the whole of a string to another string @(as stringName != "y" apparently always evaluates to true, even when the string is "y").
c) The example code I can find doesn't do this exactly how you say. There's a faster way to do it (there may be a library function that gives the total count of a character in a string, but the code I've seen was poorly formatted, so I struggled reading it).
I'm guessing you got ninja'd by shuffle.