0% found this document useful (0 votes)
22 views2 pages

Department of Information Technology

This document contains a student's experiment submission for their Java class. It includes the student's details, date, instructor, and aim of the experiment to write a program to count the number of vowels, consonants, blank spaces, and special characters in a given string. The program uses a for loop to iterate through each character of the input string and check its character code to categorize it and increment the appropriate counter. It then prints out the final count for each category.

Uploaded by

Parvi Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Department of Information Technology

This document contains a student's experiment submission for their Java class. It includes the student's details, date, instructor, and aim of the experiment to write a program to count the number of vowels, consonants, blank spaces, and special characters in a given string. The program uses a for loop to iterate through each character of the input string and check its character code to categorize it and increment the appropriate counter. It then prints out the final count for each category.

Uploaded by

Parvi Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Department of Information Technology

Academic Year: 2019-20 Name of Student: Parvi Agrawal


Semester: III Student ID: 18104018
Class / Branch: IT Date of Performance:02/08/19
Subject: JAVA Date of Submission:02/08/19
Name of Instructor: Rujata Chaudhari

Experiment No. 3

AIM : Write a java program to count number of vowels, consonants, blank spaces &
Special Characters from the given string .

Program :
import java.util.*;
class ABC123
{
static int i,v=0,c=0,sp=0,n=0;
static char ch;
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
System.out.println("ENTER STRING:");
String s1=s.nextLine();
for(i=0;i<s1.length();i++)
{
ch=s1.charAt(i);
if(ch=='A'||ch=='a'||ch=='E'||ch=='e'||ch=='I'||ch=='i'||ch=='O'||ch=='o'||
ch=='U'||ch=='u')
v++;
else if(ch=='0'||ch=='1'||ch=='2'||ch=='3'||ch=='4'||ch=='5'||ch=='6'||
ch=='7'||ch=='8'||ch=='9')n++;
else if(ch==' ')
sp++;
else
c++;
}
System.out.println("NO. OF VOWELS:"+v);
System.out.println("NO. OF DIGITS:"+n);
System.out.println("NO. OF SPACES:"+sp);
System.out.println("NO. OF CONSONANTS:"+c);
}
}

Output :

You might also like