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
Search engines enable you to
Phoenix [80]

Located web pages related to a specific subject


Please let me know if you have questions !

4 0
3 years ago
Why would businesses apply cell protection to spreadsheet entries? Provide one specific example.
docker41 [41]

Answer:

To protect a formula

Explanation:

One common example to apply cell protection to spreadsheet entries is to protect a formula used in the sheet to calculate payouts or rankings for example.   A manager might want to share the results of the team to all its team and provides some ranking or other form of calculations in the sheet.  He then needs to protect the formula so it's not altered by the team members or anyone else reviewing the file.

6 0
3 years ago
Java provides a number of interfaces and classes to systematically implement collections.
solmaris [256]

Answer:

A) True

Explanation:

Java provides collections architecture or framework used to store and manipulate a group of objects or collections.

The collection framework has interfaces which include; Set, Queue, Deque, List, as well as classes which include; Hashset, ArrayList, LinkedList, LinkedHashset, PriorityQueue, Vector and TreeSet.

There are also many methods declared in the collection interface which include; add(), addAll(), remove(), removeAll(),retainAll(), clear(), size(), iterator(), toArray() etc

4 0
3 years ago
A virus that is embedded in the automatically executing scipts commonly found in word processors, spreadsheets, and database app
schepotkina [342]

Answer:

macro virus

Explanation:

Macro virus -

A micro virus is written in a micro language  , where the programming language is present in the application of software like the powerpoint , excel , microsoft office , word processor , etc.

These virus gets activated as soon as the file is opened and then the virus starts to spread all over the system .

The virus may be send via email , and as soon as the file is opened , the macro virus gets activated.

Hence, from the given information of the question,

The correct term is macro virus.

6 0
3 years ago
Read 2 more answers
You can edit existing conditional formatting _____ from the conditional formatting rules manager dialog box.
Lera25 [3.4K]
I believe the term you're looking for would be "rules" 
send me a message if not true.
7 0
3 years ago
Other questions:
  • Here are the codes for producer and consumer problems.
    10·1 answer
  • Select the correct answer.
    13·1 answer
  • Can someone please help??
    12·1 answer
  • Which field of study would be most useful for a person who wants to work in a recycling plant?
    12·2 answers
  • How many pieces can be connected on to a to an SPS​
    11·1 answer
  • What is the second step when designing an algorithm?
    12·2 answers
  • I'm getting pretty desperate plz help me, I'll give brainiest, and ill make a free question worth 100 points this is for coding
    10·1 answer
  • Why should we not underestimate the widespread of mass media?
    13·1 answer
  • Life without internet points
    7·2 answers
  • In how many positions are there nucleotide differences between your query sequence and the sequence of accession AY259214.1
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!