Created
November 6, 2019 13:49
-
-
Save gitaficionado/73089f4deea2029f535bfb4c828e214c to your computer and use it in GitHub Desktop.
(Count vowels and consonants) Assume letters A,E,I,O, and U as the vowels. Write a program that prompts the user to enter a string and displays the number of vowels and consonants in the string
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
import java.util.Scanner; | |
public class CountVowelsAndConsonantsExercise_05_49 { | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
System.out.print("Enter a string: "); | |
//Create string input form user | |
_____________________________ | |
int countVowels = __; | |
int countConsonants = __; | |
for (int i = 0; i < s.length(); i++) { | |
__________ temp = Character.toUpperCase(s.charAt(i)); | |
if (temp == '__' || temp == '__' || temp == '___' || temp == '__' || temp == '__') | |
___________________; | |
else if (Character.isLetter(temp)) | |
countConsonants++; | |
} | |
System.out.println("The number of vowels is " + ____________); | |
System.out.println("The number of consonants is " + _________________); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment