generated from microsoft/vscode-remote-try-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(4.4.1): Finish U4_L4_Activity_One
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package Unit4; | ||
|
||
import java.util.Scanner; | ||
|
||
public class U4_L4_Activity_One { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
String string = scanner.nextLine().toLowerCase(); | ||
int pTimes = 0; | ||
|
||
for (int i = 0; i < string.length(); i++) { | ||
if (string.substring(i, i + 1).equals("p")) { | ||
String nextLetter = string.substring(i + 1, i + 2); | ||
boolean isVowel = nextLetter.equals("a") || | ||
nextLetter.equals("e") || | ||
nextLetter.equals("i") || | ||
nextLetter.equals("i") || | ||
nextLetter.equals("o") || | ||
nextLetter.equals("u"); | ||
|
||
if (isVowel) { | ||
pTimes++; | ||
} | ||
} | ||
} | ||
|
||
System.out.println("Contains p followed by a vowel " + pTimes + " times."); | ||
scanner.close(); | ||
} | ||
|
||
} |