-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab10.java
36 lines (30 loc) · 901 Bytes
/
Lab10.java
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
//***********************************************
//Aziah Blanding
//Lab 10
//November 8, 2021
//Using return method and finding # of vowels
//************************************************
import java.util.Scanner;
public class Lab10
{
public static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
System.out.print("Enter a sequence of characters: ");
String characters = console.nextLine();
int vowel = 0;
//count vowels with loop
for(int i = 0; i < characters.length(); i++)
{
vowel += isVowel(characters.charAt(i));
}
System.out.println("Number of vowels: "+vowel);
}
public static int isVowel(char tfvalue)
{
if (tfvalue == 'a' || tfvalue == 'A' || tfvalue == 'e' || tfvalue == 'E' || tfvalue == 'i' || tfvalue == 'I'|| tfvalue == 'o'|| tfvalue == 'O'|| tfvalue == 'u'|| tfvalue == 'U')
return 1;
else
return 0;
}
}