Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package alphabet;
- public class Alphabet {
- public static void main(String[] args) {
- // java program that prints letters from 'a' to 'z'
- // vowels (including 'y') are identified to user, all others identified as constants
- // @ author Renee Waggoner
- // intializing
- char alph = 'a';
- // go all the way through the whole alphabet
- while(alph<='z')
- {
- // instructions for vowels in body of nested switch
- switch(alph) {
- case 'a':
- // identifying 'a' as a vowel, and so on for each case
- System.out.println('a' + " is a vowel");
- break;
- case 'e':
- System.out.println('e' + " is a vowel");
- break;
- case 'i':
- System.out.println('i' + " is a vowel");
- break;
- case 'o':
- System.out.println('o' + " is a vowel");
- break;
- case 'u':
- System.out.println('u' + " is a vowel");
- break;
- case 'y':
- System.out.println('y' + " is a vowel");
- break;
- // all other letters will be identified as constants
- default:
- System.out.println(alph + " is a constant");
- }
- // incrementing by one so that char doesn't get stuck in a never ending loop
- alph += 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement