Print vowels with words in Java
•
Java
I'm a beginner of Java. I'm learning this course and need some help Basically, the user will enter a string and the program will print out vowels on only one line
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner inp = new Scanner(system.in);
System.out.print("In:");
String word = inp.nextLine();
//write your code below
for(int whatsat = 0; whatsat < word.length(); whatsat++){
if (word.charAt(whatsat).equals("a")){ //how to declare mutiple letters?
System.out.print(word.charAt(whatsat));
}
}
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码