⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countvowels.java

📁 《A first book of java》by Gary J.Bronson 北大出版社
💻 JAVA
字号:
import java.io.*;
public class CountVowels
{
  public static void main (String[] args) 
  {
    
    String str = new String("Counting the number of vowels");
    int i, numChars;
    int vowelCount = 0;

    System.out.println("The string: " + str);
    
    numChars = str.length();
    for (i = 0; i < numChars; i++)
    {
      switch(str.charAt(i))   // here is where a character is retrieved
      {
        case 'a': 
        case 'e': 
        case 'i': 
        case 'o': 
        case 'u':
          vowelCount++;   
      }
    }

    System.out.println("has " + vowelCount + " vowels.");
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -