0% found this document useful (0 votes)
2 views

Public Class VowelCounter {

The document contains a Java program that counts the number of vowels in a given string, 'Hello World'. It iterates through each character of the string and checks if it is a vowel, incrementing a counter accordingly. Finally, it prints the total number of vowels found.

Uploaded by

harritjevi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Public Class VowelCounter {

The document contains a Java program that counts the number of vowels in a given string, 'Hello World'. It iterates through each character of the string and checks if it is a vowel, incrementing a counter accordingly. Finally, it prints the total number of vowels found.

Uploaded by

harritjevi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Program to calculate number of vowels:

public class VowelCounter {

public static void main(String[] args) {

String input = "Hello World";

int count = 0;

for (int i = 0; i < input.length(); i++) {

char ch = input.charAt(i);

if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||

ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') {

count++;

System.out.println("Number of vowels: " + count);

You might also like