1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
crimeas [40]
2 years ago
7

8. Given the array String[] words, which already contains 1 or more values, write a block of code which counts and returns the n

umber of words which start with the letter k
Computers and Technology
1 answer:
Vikentia [17]2 years ago
7 0

Answer:

Following are the code to this question:

public class Main//defining a class

{

public static void main(String[] arg)//defining main method

{

  String[] words={"Key","day", "Know", "kind"};//defining array of String words

  int x=0;//defining integer variable for count value

  for(int i=0;i<words.length;i++)//defining for loop for count value

  {

 if(words[i].startsWith("k")||words[i].startsWith("K"))//use if block to check word start from k

  x=x+1;//increment the value of x

  }

System.out.print("The number of letters which starts from k is: "+ x);//print value with message

}

}

Output:

The number of letters which starts from k is: 3

Explanation:

In this code, inside the main method an array of String "words" is defined that hold a value, and in the next step an integer variable "x" is defined, which is used to count the letters, which starts from k.

For this, a for loop is used that counts the value and in this an, if block is defined that uses the "startsWith" method to check the value and increment the value of x and at the last, it prints its value.

You might be interested in
Putting commands in correct order so computers can read the commands
lana66690 [7]

Answer:

its b I think I'm pretty sure

8 0
2 years ago
Hard disk works on the following technologies: (i) Technology used within the hard drive to read &amp; write data to the drive a
Alex787 [66]

Answer:

The green-blue circuit board you can see in the first photo includes the disk controller, a circuit that allows the computer to operate the drive's mechanisms and read/write data to and from it. ... A small hard drive typically has only one platter, but each side of it has a magnetic coating

Explanation:

8 0
2 years ago
A cell reference with only one dollar sign before either the column or the row is called an absolute reference.
BlackZzzverrR [31]
False, absolute references have two dollar signs
4 0
3 years ago
If x is an int, which of the following statements adds 5 to the current value of x and stores the new value back in x?
faust18 [17]
X += 5;

----------------------------
6 0
3 years ago
25 POINTS!! NEED HELP ASAP!! Which of the following can be a problem for people with certain kinds of epilepsy?
olga_2 [115]
There is your answer:
Flashing images
5 0
2 years ago
Other questions:
  • To include totals and other statistics at the bottom of a datasheet, click the ____ button on the HOME tab to include the Total
    12·1 answer
  • Who is typically considered to be the father of computing
    6·1 answer
  • Crop marks are used on an illustration to indicate to the printer the
    10·1 answer
  • What is a fax machine used for
    9·1 answer
  • A ____ is an image designed to enhance a presentation (such as an electronic slide show or a printed report visually, typically
    15·1 answer
  • Write a program that prompts the user to enter the minutes (e.g., 1 billion), and displays the number of years and days for the
    13·1 answer
  • If you ping a device, you are using the __________ protocol.
    7·2 answers
  • Henry must choose which type of smart speaker to use in his home. He asked you to help him decide which one will best suit his n
    8·1 answer
  • Which of these lines of code will increment a variable?
    11·1 answer
  • Yusuke has been a fan of online games for as long as she can remember. She particularly loves the role-playing games that allow
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!