InterviewSolution
Saved Bookmarks
| 1. |
Write a program to calculate the total number of character(INCLUDE SPACES, EXCEPT VOWELS) in a string entered by user. |
Answer» ONG>Answer:Program:-import java.util.*; public class Demo { public static void main(String ARGS[ ]) { Scanner in=new Scanner(System.in); int c=0,p; String ST; char ch; System.out.println("Enter a String"); st=in.nextLine(); p=st.length(); for(int i=0;i { ch=st.charAt(i); if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'||ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u') { continue; } else c++; } System.out.println("The NUMBER of Characters and spaces="+c); } } Refer to the attachment:-
Explanation of input:-I love BLUEJ
|
|