Returns the number of times that a digit appears in text

Assignment Help Computer Engineering
Reference no: EM132197998

Question :

Write the countDigits method that returns the number of times that a digit appears in text, which is a String that may be empty or may contain words and digits. For example:

countDigits("I told him 100 times to stop") returns 3 because the string "100" contains three digits and appears in text. Note,

• Your method returns 0 if presented with the empty string;

• You may use only the String methods used in class: charAt( int ), indexOf( char) and/or length();

• Your method can use at most one Java iteration statement (either a for, a while

or a do-while statement); and

• Your method may go through the text only once.

static int countDigits( String text ) { String digits = "0123456789"; int count = 0;

Reference no: EM132197998

Questions Cloud

Calculate company X shares using cash flow valuation method : Weighted average cost of capital - 10% and Long-term FCF growth rate - 3%. According to the discounted cash flow valuation method, Company X shares are
Describe the three-step iteration process : Discuss/describe the Three-Step Iteration process and how the process may apply to your team's innovation concept generation process that may include.
Write a constructor for a deck class that create pinochle : Write a constructor (you choose the signature) for a Deck class that creates a 48 card Pinochle deck.
What advise will you give to your roommate : Your roommate and you have automobile insurance policies with identical coverage written by the same insur- ance company. You both drive the same year.
Returns the number of times that a digit appears in text : Write the countDigits method that returns the number of times that a digit appears in text, which is a String that may be empty or may contain words.
Illustrate the effect of a decrease in the quantity : Illustrate the effect of a 10% decrease in the quantity demanded by China for milk powder. Show how this will affect world prices, New Zealand exports.
Write a program for a university registration system : Your program will select the actual class size randomly. The size is selected randomly and must be between half of the maximum and the maximum inclusive.
Write a decision statement to check that the value : Write a decision statement to check that the value of an integer variable "x" is between 45 and 75. If it is, display YES, otherwise display NO.
Make a two dimensional graph of the electric field lines : Write a computer program using Matlab to make a two dimensional graph of the electric field lines and the equipotential surfaces due to a particular set.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a single c statement that sets to 1 the sign

Write a single C statement that sets to one bits 7, 9 and 11 of N, leaving the remaining bits unchanged. (Bit 0 is the least significant bit.)

  Create an erd based on the crows foot notation

Use the following business rules to create a Crow's Foot ERD. Write all appropriate connectivities and cardinalities in the ERD.

  Define global security describe how they are involved

ntify Organizations involved in Global Security describe how they are involved

  Calculate the rate of heat transfer in steady operation

A spherical vessel, with 30.0-cm outside diameter, is used as a reactor for a slow endothermic reaction. The vessel is completely submerged in a large.

  What are two advantage of encrypting data stored in database

What are two advantages of encrypting data stored in the database? Suggest a scheme for the secure storage of passwords.

  Describe categories of project success measures

List and describe the four different categories of project success measures. During which stage of a project are most risks typically uncovered?

  Create a bankaccount class that can used to maintain balance

Create a BankAccount class that can be used to maintain a bank account balance. Include appropriate constructors, properties, and methods to enable the account.

  How the operations work to ensure different aspects

Supplement the description with your own intuitions and analysis of how these operations work to ensure different aspects of secure communication.

  Draw an er diagram that captures the preceding information

The Prescriptions-R-X chain of pharmacies has offered to give you a free lifetime supply of medicine if you design its database.

  Compute the quantization error sequences

Quantization Experiments Use fxquant ( ) to quantize the 8000 input speech samples from the file S5 . MAT. Using rounding and saturation.

  Draw the invoice in html for presentation on the web

To appreciate this flaw, imagine the changes that would be necessary to draw the invoice in HTML for presentation on the Web.

  Distinguish between an mdc and a mac

Associate each birthday problem with one of the attacks on a hash function. Distinguish between an MDC and a MAC. Distinguish between HMAC and CMAC.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd