Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

Why We Form Relationships Managing Relationship Dynamics?

Answered: 1 week ago