-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode_V.java
More file actions
61 lines (61 loc) · 1.68 KB
/
Node_V.java
File metadata and controls
61 lines (61 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.io.*;
public class Node_V
{
String data;
Node_V ob;
Node_V()
{
data="";ob=null;
}
void create()throws IOException
{
int n;
BufferedReader as=new BufferedReader(new InputStreamReader(System.in));
System.out.print("\t -NODES BEGINNING WITH VOWEL COUNTER- \n\nEnter the Number of nodes to be created:");
n=Integer.valueOf(as.readLine());
String x;
System.out.print("Enter The first data:");
x=as.readLine();
this.data=x;
Node_V temp;
Node_V ptr=this;
ptr.ob=null;
for(int i=1;i<n;i++)
{
temp=new Node_V();
if(i!=(n-1))
System.out.print("Enter the data:");
else
System.out.print("Enter the Last data:");
temp.data=as.readLine();
temp.ob=null;
ptr.ob=temp;
temp=null;
ptr=ptr.ob;
}
temp=ob;
System.out.print("The Data in the Linked List:\n |"+this.data+"|->");
if(n!=1)
{
while(temp.ob!=null)
{
System.out.print("|"+temp.data+"|->");
temp=temp.ob;
}
System.out.println("|"+temp.data+"|");
}
System.out.println("Number of NODES that begins with vowels:");
System.out.println(count_vowel(this));
}
int count_vowel(Node_V start)
{
Node_V temp=new Node_V(); temp=start;int c=0;char ch;
while(temp!=null)
{
ch=Character.toLowerCase((temp.data).charAt(0));
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
c++;
temp=temp.ob;
}return c;
}
}