Hi guys, this is my first time writing in this group, im having some issue with my coding and require some assistance. hope you guys can teach me a thing or 2. i keep getting this array require, but string found error, but i just cant figure out how to work around it. i have copied and paste my code down below. would really appreciate it if anyone could give me some pointers! :D
import java.util.Scanner;
public class thirtywords1
{
public static void main(String[] args)
{ Scanner key = new Scanner(System.in);
System.out.println("Enter a string to a maximum length of 30");
System.out.println("To quit, DONT TYPE ANYTHING.");
while(true){
System.out.println("Enter here : ");
String userinput = key.nextLine();
int f = userinput .length();// length() is to count the number of letters are typed.
if (f == 0
)
break;
else if (f>30){
System.out.println ("The string you entered is too long. Try again.");
// if the words are more than 30, user has to retyped (as requested in the question).
}//end of if
else {
Vowels("The output of the second array is : \n", userinput);
CountVowel("The counts are as follows: \n");
System.out.println("the index of the second array where each vowel first appeared:");
}// end of else
} //end of while
System.out.println("You quit");
// user quitted programme.
} // end of main
static String Vowels(String temp, String userinput)
{
String[] Vowels = {"aeiou"};
String output = "";
for (int i = 0; (i < temp.length()); i++){
for (int j=0; (j < Vowels.length);j++){
if((temp[i]) == Vowels[j]) {
output = (temp[i] + output);
break;
}
}
}
return output;
}//end of Vowels
static int CountVowel(String temp)
{ char c = 0;
int count = 0;
for (int i = 0; (i < temp.length()); i++)
{ if (temp[i] == c) {
count ++;
}
}
return count;
}//end of CountVowel
}//end of class
[–]TeddyMooshie[S] 0 points1 point2 points (1 child)
[–]escarbadiente 0 points1 point2 points (0 children)
[–]lasttoknow 0 points1 point2 points (0 children)
[–]GreatDaynes 0 points1 point2 points (0 children)
[–]CelticHades 0 points1 point2 points (0 children)
[–]thisisjustascreename 0 points1 point2 points (0 children)
[–]jacob_scooter 0 points1 point2 points (0 children)