Question
(JAVA) Using the provided code , write a program that counts the number of consonants in a given single-word String and prints that value to
(JAVA)
Using the provided code , write a program that counts the number of consonants in a given single-word String and prints that value to the console. Consonants are everything that is not an a, e, i, o, or u, and the case does not matter. You may assume that only letters and no other characters, like digits or special characters, will be used, and it will be a single word. The printout to the console should follow the format:
The number of consonants is: <
Values denoted in << >> represent variable values, and everything else are literal values (make sure to follow spelling, capitalization, punctuation, and spacing exactly).
PROVIDED CODE
import java.util.Scanner; public class Question02 {
public static void main(String[] args) { Scanner keyboard; if(args == null || args.length == 0) { keyboard = new Scanner(System.in); System.out.println("Welcome to the consonant counter program! I will count the number of consonants in a word."); } else { keyboard = new Scanner(args[0]); } //----------------------------------------------------------------------------------- //Write your solution here }//Do not alter this //Space for other methods if necessary----------------------------------------------- //Write those here if necessary //----------------------------------------------------------------------------------- }//Do not alter this
Solution Tests:
- If the user enters the following input HelloWorld then does the program print out:
The number of consonants is: 7
- If the user enters the following input aeiou then does the program print out:
The number of consonants is: 0
- If the user enters the following input AbCdEfGhIjKlM then does the program print out:
The number of consonants is: 10
PLEASE PROVIDE BREIF SUMMARY/ DESCRIPTION OF HOW YOU GOT THE PROGRAM TO WORK (METHODS USED, ETC..)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started