Write and execute a PYTHON program to perform separate files for each of the tasks
1.To find the number of vowels in a sentence.
import java.util.Scanner;
public class CountingVowels {
public static void main(String args[]){
int count = 0;
System.out.println("Enter a sentence :");
Scanner sc = new Scanner(System.in);
String sentence = sc.nextLine();
for (int i=0 ; i<sentence.length(); i++){
char ch = sentence.charAt(i);
if(ch == 'a'|| ch == 'e'|| ch == 'i' ||ch == 'o' ||ch == 'u'||ch == ' '){
count ++;
}
}
System.out.println("Number of vowels in the given sentence is "+count);
}
}
Comments
Leave a comment