>i am now getting the following error msg
Then you're not using the function correctly.
>The code you used isn't anything like what we have been taught as of yet.
Well, since you haven't mentioned your level of experience I have to make some assumptions or dumb down my code so much as to risk insulting you. Here, this doesn't use Strings or arrays, but it's significantly larger even when the histogram method is used:
/*
Description: Simple vowel histogram program
Author: Julienne (Narue) Guth
Creation: 20041106
*/
package scratchpad;
import java.io.*;
public class Main {
public static void print_histogram ( final char ch, int freq ) {
System.out.print ( ch + ": " );
for ( int i = 0; i < freq; i++ )
System.out.print ( "*" );
System.out.println();
}
public static void main ( String[] args ) throws IOException {
int ca, ce, ci, co, cu;
char ch;
ca = ce = ci = co = cu = 0;
while ( ( ch = (char)System.in.read() ) != -1 && ch != '\n' ) {
ch = Character.toUpperCase ( ch );
if ( ch == 'A' )
++ca;
else if ( ch == 'E' )
++ce;
else if ( ch == 'I' )
++ci;
else if ( ch == 'O' )
++co;
else if ( ch == 'U' )
++cu;
}
print_histogram ( 'A', ca );
print_histogram ( 'E', ce );
print_histogram ( 'I', ci );
print_histogram ( 'O', co );
print_histogram ( 'U', cu );
}
}
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Offline 11,807 posts
since Sep 2004