Array of Characters, Need Help

Please i am new to java. Can someone kindly give me a java code that will do this Assignment ?

Write a function that accepts a character array as input, counts the number of occurrences of each character in the array, and outputs the results in a format like the following (characters that do not occur in the input array are not displayed in output)

a - **

c - ****

e - *

For example, if input were {慶? 慹? 慹? 慹? 慳? 憅拀, the output would be:

a - *

c - *

e- ***

q - *

Thank you all.

[547 byte] By [mofaloksa] at [2007-11-27 3:20:57]
# 1

> Please i am new to java. Can someone kindly give me a

> java code that will do this Assignment ?

i guess not

>

> Write a function that accepts a character array as

> input, counts the number of occurrences of each

> character in the array, and outputs the results in a

> format like the following (characters that do not

> occur in the input array are not displayed in

> output)

>

>

> a - **

>

> c - ****

>

> e - *

>

>

> For example, if input were {慶? 慹? 慹? 慹? 慳?

> 憅拀, the output would be:

>

>

> a - *

>

> c - *

>

> e- ***

>

> q - *

>

there are lots of way to do this ; i give you one:

- create a two dimensions table of int new int [26][2]; (i take 26 for the 26 letters of the alphabet)

- each letter of the alphabet will be filled in the first dimension ; the second dimension will be to count occurence of each letter

- you browse the input, and increment total for each character

- once this is over, you browse your int[][] table using the second dimension to determine how much * you must write for each character

> Thank you all.

you re welcome

EDIT: you can also use a HashMap<Character, Integer> if you don't like the first solution

calvino_inda at 2007-7-12 8:23:41 > top of Java-index,Java Essentials,Java Programming...