Preview

Vowel Consonants Count Using Java

Satisfactory Essays
Open Document
Open Document
277 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Vowel Consonants Count Using Java
package vowelCons; import java.util.Scanner; public class VowelCons { public static void main(String args[]){ String input; char selection; int x = 0; char[] a = new char[100]; Scanner keyboard = new Scanner(System.in); System.out.print("Enter a string: "); input = keyboard.nextLine(); x = input.length(); //Convert from String to Char for (int p = 0; p < x; p++) { a[p] = input.charAt(p); // in these couple lines here. }

// Determine amount of Vowels and Cons int Vowels = 0; int Cons = 0; for (int i = 0; i < 100 ; i++){ if (a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u'){ Vowels++; }else{ Cons++; } }

// Switch case to determine which Menu was Selected and Print corresponding Results do{ selection = getMenuSelection(); switch(Character.toLowerCase(selection)) { case 'a' : System.out.println("\nNumber of vowels: " + Vowels); break; case 'b' : System.out.println("\nNumber of Consonats: " + Cons); break; case 'c' : System.out.println("\nNumber of vowels: " + Vowels); System.out.println("\nNumber of Consonants: " + Cons); break; case 'd': System.out.print("Enter a String: "); input = keyboard.nextLine(); break; } } while (Character.toLowerCase(selection)!='e'); } public static char getMenuSelection() { String input; char selection;

You May Also Find These Documents Helpful

  • Good Essays

    letter → A | B | C | … | Z | a | b | … | z…

    • 703 Words
    • 3 Pages
    Good Essays
  • Good Essays

    PRG/420 Week 3

    • 1025 Words
    • 5 Pages

    /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package commission2; import java.lang. *; import java.text. DecimalFormat; import java.util.…

    • 1025 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    19.Write a program that prompts the user to enter a character and on subsequence line print its ASCII code in binary and the number of 1 bit in its ASCII code. Page: 136…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    math 239 assignment 1

    • 1831 Words
    • 8 Pages

    A1 ; i2 letters A2 ; . . . ; in letters An (where i1 , . . . , in are some non-negative integers). Find a formula…

    • 1831 Words
    • 8 Pages
    Good Essays
  • Satisfactory Essays

    Cosc-2436-73426 Project 2

    • 306 Words
    • 2 Pages

    return I // if x is found in A[I] the function returns I and terminates…

    • 306 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Unit 5 22 Test 2 Part 2

    • 2021 Words
    • 11 Pages

    # A# A# A# #9 # #9 #9 #9 #9 #9 #9 $ w; �# #> J (9 # I# A# ## ## " A# A# (9 I# I#…

    • 2021 Words
    • 11 Pages
    Powerful Essays
  • Satisfactory Essays

    Nvcc Class Schedule

    • 493 Words
    • 2 Pages

    Trans Code* (circle) A D A D A D A D A D A D A D A D A D…

    • 493 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Lab_6_solution

    • 1259 Words
    • 3 Pages

    By the end of this lab session, you will be able to - declare an integer and character array - assign values to array during compilation and during execution - print contents of an array using repetition structure SAMPLE PROGRAM 1 /1. A program reads a series of numbers and print it reversed / include stdio.h void main (void) int i, Num, numbers10 printf(You may enter up to 10 integersn) printf(How many integers would you like to enter ) scanf (d, Num) if (Num 10) Num 10 printf(nEnter your numbers ) for (i 0 i Num i) scanf(d, numbersi) printf(nYour numbers reversed are ) for (i Num - 1 i 0 --i) printf(d , numbersi) printf(nn) SAMPLE PROGRAM 2 /2. Program that demonstrates the use of for loop to accept 8 numbers from user and displays certain numbers from the array / includestdio.h void main() int num, numbers8 printf(You need to enter 8 numbers ... n) for(num 0 num 7 num) scanf(i,numbersnum) printf(nn) printf(Your 1st element is dn,numbers0) printf(Your 2nd element is dn,numbers1) printf(Your 3rd element is dn,numbers2) printf(Your 8th element is dn,numbers7) printf(nn) printf(nnAll together your numbers aren) for(num 0 num 7 num) printf(d ,numbersnum) printf(nn) SAMPLE PROGRAM 3 /3. Program declares an array called charArray and assigns a single character to each of the array element using the initialize braces. Finally, the program prints the content of the array. / includestdio.h void main() char charArray8 F,r,i,e,n,d,s int i for(i 0 i 7 i) printf(charArrayd has a value of cn,i, charArrayi) printf(nMy favourite comedy sitcom is snn, charArray) SAMPLE PROGRAM 4 /4. Program consists of arrays (i.e. integer array and character array). It uses loops to sort the integer array elements in ascending and descending order. Then it displays the contents of the array elements respectively. / includestdio.h void main(void) int array10 0,1,2,3,4,5,6,7,8,9, i char string20 This is a string for(i…

    • 1259 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    English unstressed reduced vowels, such as schwa '[ə]' and barred-i '[ɨ]', have phonetic features that are distinct from other vowels. Phonetic features of those vowels are reduced in duration and vowel quality (F1 and F2). Schwa '[ə]' occurs in a word-final position like Rosa as a mid central reduced vowel and barred-i '[ɨ]' occurs in a non-final position like roses as a high central reduced vowel (Flemming & Johnson 2007). In contrast to English, there is no stress in Korean phonological system and thus stress-related vowel reduction phenomenon does not arise in Korean. Moreover, '/ə/' and '/ɨ/' that are similar to English unstressed vowels ([ə], [ɨ]) exist as full vowels in Korean. This different prosodic system provides Korean learners of English with difficulty to accurately produce English unstressed vowels (McAllister, Fledge, & Piske 2002).…

    • 453 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Analysis of Two Way Table

    • 6239 Words
    • 25 Pages

    yij i= 1,2 ,…,I j= 1,2,…,J and displayed in a rectangular array as shown below…

    • 6239 Words
    • 25 Pages
    Good Essays
  • Good Essays

    // save A[i], the value that will be inserted into the array on this iteration…

    • 470 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Char D1

    • 599 Words
    • 3 Pages

    int ReadDials (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8);…

    • 599 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Java Calculator CMD

    • 889 Words
    • 4 Pages

    import java.util. *; class pup { public static void main (String [] args) { int a,b,op; int c = 0; Scanner fSC = new Scanner(System.in); System.out.println("Welcome to CMD basic calculator!\n"+"Press ENTER key to continue . . ."); Scanner aKey = new Scanner(System.in); String akeyp = aKey.nextLine(); System.out.println("Enter first number:"); a = fSC.nextInt(); System.out.println("Input operator to be used( Ex. 1):\n"+"1. Addition\n"+"2. Subtraction\n"+"3. Multiplication\n"+"4.…

    • 889 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    数据结构C语言版 串的块链存储表示和实现.txt成熟不是心变老,而是眼泪在眼里打转却还保持微笑。把一切平凡的事做好既不平凡,把一切简单的事做对既不简单。/* 数据结构C语言版 串的块链存储表示和实现 P78 编译环境:Dev-C++ 4.9.9.2 日期:2011年2月12日 */ #include #include #include #include // LString.h 串的块链存储表示 #define CHUNKSIZE 4 // 可由用户定义的块大小 typedef struct Chunk { char ch[CHUNKSIZE]; //块的数据域 struct Chunk *next; //块的指针域 }Chunk; typedef struct { Chunk *head, // 串的头指针 *tail; // 串的尾指针 int curlen; // 串的当前长度 }LString; char blank = '#'; // 全局变量,用于填补空余 // 初始化(产生空串)字符串T。 void InitString(LString *T) { (*T).curlen=0; (*T).head=…

    • 1320 Words
    • 6 Pages
    Good Essays
  • Satisfactory Essays

    11. Write a program that allows the user to enter students’ names followed by their test scores and outputs the following information (assume that maximum number of students is 50):…

    • 296 Words
    • 2 Pages
    Satisfactory Essays

Related Topics