Create a class which ask the user to enter a sentence and it should display count of each vowel type in the sentence The program should continue till user enters a word quit

Create a class which ask the user to enter a sentence and it should display count of each vowel type in the sentence The program should continue till user enters a word quit

Hello friends i hope you like my previous post, in today’s post we are going discuss about, “Create a class which ask the user to enter a sentence and it should display count of each vowel type in the sentence The program should continue till user enters a word quit”  

(note : programs based on gtu syllabus)

so you have to Create a class which ask the user to enter a sentence and it should display count of each vowel type in the sentence The program should continue till user enters a word quit

so now let’s discuss the logic, how you can implement it

First define the variables in main class

  • Integer
    •  x = 0
    •  A = 0
    •  E = 0
    •  I = 0
    •  O = 0
    •  U = 0
  • Char
    • ch
  • String
    • str

you have to take Word from user so you have to make use of Scanner class and store the user input in string variable “str

in this program condition is given that you have to take input from user until user not enters “quit” word

So, you have to use while loop and you have to check the input every time user enters word

if input word is “quit” then break(exit) from loop else count How many number of vowels in that word using for loop and  if condition

Example :

for identifying char is vowel or not you have to get value character by character from word and compare using if condition

as you can see in above example every time we found any vowel we incremented the corresponding variable [Ex : if we found vowel “i” we increment variable int i ]

and now print all the variable corresponding to each vowel using System.out.println(); 

Example :

so here your program “Create a class which ask the user to enter a sentence and it should display count of each vowel type in the sentence The program should continue till user enters a word quit” completed

Check Out other post – Write a program to find that given number or string is palindrome or not

so here your program’s solution, check program below the post for reference

these are the java basic programs based on gtu syllabus

Program :

OUTPUT :

Create a class which ask the user to enter a sentence and it should display count of each vowel type in the sentence The program should continue till user enters a word quit

Program As per GTU Syllabus

if you like the the way of explanation tell us in comment section you can also write the queries about this program we are defiantly going reply

share this post with your college friends so everyone can get benefit of it good bye friends see you in next post happy coding

You May Also Like

About the Author: TheCoder

Leave a Reply

Your email address will not be published. Required fields are marked *