Computer Science, asked by muskanjyoti1916, 1 year ago

Write a program in Java to print all consonants of a word in front and rest vowel at the last.

Answers

Answered by darshansharma97
1
There you go another program using if else statement with sample outputs – learn more about if else statement here.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

import java.util.Scanner;

class Char

{

public static void main(String[ ] arg)

{

int i=0;

Scanner sc=new Scanner(System.in);

System.out.println("Enter a character : ");

char ch=sc.next( ).charAt(0);

if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')

{

System.out.println("Entered character "+ch+" is  Vowel");

}

else if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))

System.out.println("Entered character "+ch+" is Consonant");

      else

System.out.println("Not an alphabet");

}


muskanjyoti1916: Actually I wanted this program using import not util
Similar questions