Design and implement an application that reads a string from the user then deter
ID: 3640767 • Letter: D
Question
Design and implement an application that reads a string from the user then determines and prints how many of eachlowercase vowel (a,e,i,o,and u) appear in the entire string.
have a separate counter for each vowel. also count and print the number of nonvowel characters.
here what I have
//**************************************************************************
//pp69.java author: jalylah aljamal
//
//***************************************************************************
import java.util.Scanner;
public class PP69
{
public static void main(String[] args)
{
char Letters, a =0, e = 0, i = 0;
char u = 0, o = 0, nonvowels = 0;
String category;
Scanner scan = new Scanner (System.in);
System.out.println("Enter a String to be processed for vowels: ");
category = scan.nextLine();
switch (letterschar)
{
case 1 :
a = a++;
System.out.println("'a' " + a );
break;
case 2 :
e = e++;
System.out.println( ", 'e' " + e );
break;
case 3:
i = i++;
System.out.println( ", 'i' " + i );
break;
case 4 :
o = o++;
System.out.println( ", 'o' " + o );
break;
case 5 :
u = u++;
System.out.println( ", 'u' " + u );
break;
case 6 :
nonvowels = nonvowels++;
System.out.println( ", nonvowels " + nonvowels);
break;
default:
System.out.println("Error: String contained no characters.");
}
}
}
Explanation / Answer
PS: Please rate the answer import java.util.Scanner; public class PP69 { public static void main(String[] args) { int a =0, e = 0, i = 0, u = 0, o = 0, nonvowels = 0; String category; Scanner scan = new Scanner (System.in); System.out.println("Enter a String to be processed for vowels: "); category = scan.nextLine(); char userstring[] = category.toCharArray(); for(int k=0; kRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.