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
DiKsa [7]
3 years ago
9

Write a function `has_more_zs` to determine which of two strings contains # more instances of the letter "z". It should take as

parameters two string # variables, and return the argument which has more occurances of the letter "z" # If neither phrase contains the letter "z", it should return: # "Neither string contains the letter z." # If the phrases contain the same number of "z"s, it should return: # "The strings have the same number of Zs." # The function must work for both capital and lowercase "z"s.
Computers and Technology
1 answer:
nekit [7.7K]3 years ago
5 0

Answer:

// Method's name: has_more_zs

// Parameters are text1 and text2 to hold the two phrases to be tested

public static String has_more_zs(String text1, String text2) {

 // Create and initialize z1 to zero

 // Use z1 to count the number of zs in text1

 int z1 = 0;

 // Create and initialize z2 to zero

 // Use z2 to count the number of zs in text2

 int z2 = 0;

 

 //Create a loop to cycle through the characters in text1

 //Increment z1 by one if the current character is a 'z'

 int i = 0;

 while (i < text1.length()) {

  if (text1.charAt(i) == 'z' || text1.charAt(i) == 'Z') {

   z1 += 1;

  }

  i++;

 }

 //Create a loop to cycle through the characters in text2

 //Increment z2 by one if the current character is a 'z'

 

 i = 0; //Re-initialize i to zero

 

 while (i < text2.length()) {

  if (text2.charAt(i) == 'z' || text2.charAt(i) == 'Z') {

   z2 += 1;

  }

  i++;

 }

 

 

 //Using the values of z1 and z2, return the necessary statements

 if (z1 > z2) {

  return "The phrase '" + text1 + "'" + " has more occurences of z than the phrase " + "'" + text2 + "'";

 }

 else if (z1 < z1) {

  return "The phrase '" + text2 + "'" + " has more occurences of z than the phrase " + "'" + text1 + "'";

 }

 else if (z1 == z2) {

  return "The strings have the same number of z";

 }

 else {

  return "Neither string contains the the letter z";

 }

}

Explanation:

Explanation to answer has been given in the code as comments. Please refer to the comments for the details of the code.

The source code file has been attached to this response and saved as "NumberOfZs.java"

Hope this helps!

Download java
You might be interested in
) The _____ method of a radio button returns true if that button is on.
Lostsunrise [7]

Answer:

isSelected()

Explanation:

The isSelected() method of a radio button returns true if that button is on and false otherwise. This method is defined in the class javax.swing.AbstractButton. JRadioButton class inherits from AbstractButton and thus has access to this method. An application code can invoke this method on the radio button instance to determine th ecurrent state and alter the control flow accordingly.

4 0
3 years ago
Which of the following statements explains why
Ahat [919]

Answer:

IT professionals often have to make logical, well-considered decisions

Explanation:

Tough-mindedness can be defined as a trait or quality that requires a person to be empiric and skeptical about something.

As a result of this, tough-mindedness is a good personality trait for IT professionals because they often have to make logical, well-considered decisions.

3 0
4 years ago
You are the senior nurse on the unit and you are orienting a new graduate LVN/LPN. One of the subjects you want to cover today i
dem82 [27]

Answer:

The correct answer to the following question will be Option D (Homans sign).

Explanation:

To medicine, the symptom of Homans is considered a sign of thrombosis by some physicians. John Homans described Homans as an annoyance under the knee of the foot to 1941 after forced dorsification.

  • Inspect the limbs for edema, pulse equality, and capillary refill.
  • Check to sign Homans.
  • Feel any warmth or redness along the Calf area.
  • Bilateral calves should be equal in size and warmth.
  • There must be no swollen, sore places, and when the woman is moving, there will be no pain in the calves.

Therefore, Option D is the right answer.

4 0
3 years ago
Write a statement that increments numUsers if updateDirection is 1, otherwise decrements numUsers. Ex: if numUsers is 8 and upda
Lady_Fox [76]

Answer:

Following are the statement is given below

if(updateDirection ==1) // check condition

{

++numUsers; // increments the value

}

else

{

--numUsers; // decrement the value

}

Explanation:

Following are the description of statement

  • Check the condition in the if block .If the "updateDirection" variable is 1 then then control moves to the if block otherwise control moves to the else block statement.
  • In the if  block the statement is "++numUsers" it means it increment the value by 1 .
  • In the else block the statement is "--numUsers" it means it decrement  the value by 1 .

4 0
3 years ago
You decide to add 3 new hard drives to your computer so that you can increase the amount of storage one it when you install them
Tasya [4]

Answer:

b. Use a Molex to SATA power adapter.

Explanation:

SATA power connector is a 15 pin power connector that is used to connect many computer parts like hard drive, cd drive, SSD, etc.

Molex connector is an old connector that is used as a power connector instead of a SATA connector on the same devices.

But the SATA connector overcomes the Molex connectors as it is easy to use and easy to install and can widely be used in many peripherals.

But even now power supply of the computer contains the SATA power connector as well as some spare Molex connector, which can be used when required.  

There are many Molex to SATA connectors that are easy to use when there is a shortage of SATA power.

So, according to the scenario, the most appropriate answer is option b.

3 0
3 years ago
Other questions:
  • Which of the following has the responsibility of offering instruction on intrusion detection systems and intrusion prevention sy
    11·1 answer
  • What technological changes at the turn of the twentieth century affected american life?
    6·1 answer
  • PLEASE HELP
    8·2 answers
  • Please write down a java program for below instruction.Min-Heap: Construct a Min_Heap from the following set of integers. Rememb
    5·1 answer
  • Here's another question!<br><br> What is some iterative programming structure uses?
    13·1 answer
  • Good ways to increase sales on phone accesories?
    10·2 answers
  • Blender is used by which video game team member?
    15·1 answer
  • What is the function of a text box in Microsoft word?​
    13·1 answer
  • HEEELLPPPPP, ILL GIVE THE BRAIN THING
    14·1 answer
  • True or False: Once you rename a field, the new field name must be used in the rest of the search string.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!