subject

Consider the following method:

public int countPs(String word)
{
int sum = 0;
for(int i = 0; i < word. length(); i++)
{
word = word. toLowerCase();
if(word. substring(i, i+1).equals("p"))
{
sum++;
}
}
return sum;
}

What would the value of sum be after the method call countPs("Peter Piper picked a pack of pickled peppers")?

7

9

2

0

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:00
The fourth generation of computers emerged between 1970s and 1980s. which technological advancement brought about this generation of computers? which computer architecture was used most in this generation?
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
What are some ways to use a range name in a formula? check all that apply. in the defined names group, click use in formula, and then select the desired name. begin typing the name in the formula, select a name from the autocomplete list, and use the arrow keys and tab key to enter the name in the formula. begin typing the formula, and then click and drag with the mouse to select the cells to include in the formula. right-click one of the cells in the range. click formula options, and use the dialog box to add the name.
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
What are the 12 colors of the spectrum called?
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
How many points do i need before i can send a chat
Answers: 1
You know the right answer?
Consider the following method:

public int countPs(String word)
{
int sum = 0...
Questions
question
Mathematics, 12.04.2020 01:32