Computer Science, asked by arbazakhtar0786, 1 month ago

Write a program that inputs a line of text and prints out the count of vowels in it.

Answers

Answered by kajalpal1975
2

Answer:

Java

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter text");

String str = sc.nextLine().toLowerCase();

int vow = 0;

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

char ch = str.charAt(i);

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

vow++;

}

}

System.out.println("No. of vowels = "+vow);

}

}

Python

str = input('Enter text\n').lower();

vow = 0

for i in str:

if i in ('a', 'e', 'i', 'o', 'u'):

vow += 1

print("No. of vowels =", vow)

Similar questions