Structure of the Problem Requirements
In this problem we will learn how to find the Number of Vowels in a string given by user . After receiving input from user convert it to lower or upper case and then in a loop define the condition of vowels . Another variables count will be update whenever a vowels find in the loop . Here is the source code of this problem which help you in better understanding .
Source Code
package com.ancodingpoint.www;
import java.util.Scanner;
public class Find_Vowels
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
String story ="";
int count =0;
System.out.println(" Enter Your Story Here .....! ");
story = input.nextLine();
story = story.toLowerCase();
for (int i = 0; i<story.length();i++)
{
if (story.charAt(i)=='a')
{
count++;
}
if (story.charAt(i)=='e')
{
count++;
}
if (story.charAt(i)=='i')
{
count++;
}
if (story.charAt(i)=='o')
{
count++;
}
if (story.charAt(i)=='u')
{
count++;
}
}
System.out.println(" Your Story Contain :" + count + " Vowels ");
}
}
Output of the Program
Java String Programming |
Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.
0 comments:
Post a Comment