Define a class to declare a character array of size ten, accept the character into the array and perform the following: • Count the number of uppercase letters in the array and print. • Count the number of vowels in the array and print
Solution :-
import java.util.*; class array{ public static void main(){ Scanner sc =new Scanner(System.in); int i,cnt=0; char a[]=new char[10]; for(i=0;i<10;i++){ System.out.println(“Enter character”); a[i]=sc.next().charAt(0); } for(i=0;i<10;i++){ if(Character.isUpperCase(a[i])){ cnt++; System.out.println(a[i]); } } System.out.println(“The number of uppercase letters in the array =”+cnt); int cntv=0; for(i=0;i<10;i++){ if(a[i]==’A’ || a[i]==’a’ || a[i]==’E’ || a[i]==’e’ || a[i]==’I’ || a[i]==’i’ || a[i]==’O’ || a[i]==’o’ || a[i]==’U’ || a[i]==’u’){ cntv++; System.out.println(a[i]); } } System.out.println(“The number of vowels in the array =”+cntv); } }
Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable
Popular Videos
Play Video
UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.
Chris Matthews
Designer
Play Video
SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.