|
| 1 | +/* |
| 2 | +Ask rahul to give two of his friends name.and help rahul to count the number of vowels present in these two names. if no vowels present thent print "0". |
| 3 | +Example |
| 4 | + |
| 5 | +Input |
| 6 | + |
| 7 | +ramesh |
| 8 | +tushar |
| 9 | + |
| 10 | +Output |
| 11 | + |
| 12 | +4 |
| 13 | + |
| 14 | +Input Format |
| 15 | + |
| 16 | +first line accept first Name |
| 17 | +second line accept 2nd Name |
| 18 | + |
| 19 | +Constraints |
| 20 | + |
| 21 | +name must contain alhabates only. |
| 22 | + |
| 23 | +Output Format |
| 24 | + |
| 25 | +First line must be no of Vowels presnt in both the names. |
| 26 | + |
| 27 | +Sample Input 0 |
| 28 | + |
| 29 | +ramesh |
| 30 | +suresh |
| 31 | +Sample Output 0 |
| 32 | + |
| 33 | +4 |
| 34 | +*/ |
| 35 | +import java.io.*; |
| 36 | +import java.util.*; |
| 37 | + |
| 38 | +public class Solution { |
| 39 | + |
| 40 | + public static void main(String[] args) { |
| 41 | + /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ |
| 42 | + Scanner sc = new Scanner(System.in); |
| 43 | + String name1 = sc.next(); |
| 44 | + String name2 = sc.next(); |
| 45 | + name1 = name1.toLowerCase(); |
| 46 | + name2 = name2.toLowerCase(); |
| 47 | + int count = 0; |
| 48 | + for(int i=0;i<name1.length();i++) |
| 49 | + { |
| 50 | + if(name1.charAt(i)=='a'||name1.charAt(i)=='e'||name1.charAt(i)=='i'||name1.charAt(i)=='o'||name1.charAt(i)=='u') |
| 51 | + count++; |
| 52 | + } |
| 53 | + for(int i=0;i<name2.length();i++) |
| 54 | + { |
| 55 | + if(name2.charAt(i)=='a'||name2.charAt(i)=='e'||name2.charAt(i)=='i'||name2.charAt(i)=='o'||name2.charAt(i)=='u') |
| 56 | + count++; |
| 57 | + } |
| 58 | + System.out.println(count); |
| 59 | +} |
| 60 | +} |
0 commit comments