/*This code counts the vowels in strings?
It has to use user defined methods:
*/
import java.lang.String;
import java.io.*;
import java.util.*;
public class vowelConsonant2
{
static Scanner scan = new Scanner(System.in);
public static void main(String args[])
{
String text;
int actualI, actualC;
System.out.println("Enter the String:");
text = scan.nextLine();
System.out.println("There are " + vowelcounter(actualI,actualC) + " vowels");
}
public static int vowelcounter(int countv , int i , char c )
{ countv = 0;
for (int i = 0; i < text.length(); i++)
{
text = text.toLowerCase();
char c = text.charAt(i);
if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
{countv++;
return countv;}
}
}
Johannady2 -5 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Johannady2 commented: /* It's still giving me the same error. vowelConsonant2.java:30: error: reached end of file while parsing } ^ 1 error */ import java.lang.String; import java.io.*; import java.util.*; public class vowelConsonant2{ static Scanner scan = new Scanner(Syste +0
Johannady2 -5 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
NormR1 563 Posting Sage Team Colleague
Johannady2 -5 Newbie Poster
NormR1 563 Posting Sage Team Colleague
Johannady2 commented: It's indented but it gets messed up when I paste it here.. :p +0
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.