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:-

  • The first photo is the program.
  • The second photo is the input.
  • The third photo is the output.

Explanation of input:-

I love BLUEJ

  • 1st space
  • 2nd l
  • 3rd v
  • 4th space
  • 5th B
  • 6th L
  • 7th J



Discussion

No Comment Found