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

Fill in this function that takes three parameters, two Strings and an int. 4- // Write some test function calls here! The String

s are the message that should be printed. You should alternate printMessage("Hi", "Karel", 5); between the Strings after each line. The int represents the total number of lines that should be printed. public void printMessage(String lineOne, String lineTwo, in For example, if you were to call 19.
printMessage("Hi", "Karel", 5);
// Start here! 12 the function should produce the following output:
Hi
Karel
Hi
Kare
Computers and Technology
1 answer:
zimovet [89]3 years ago
8 0

Answer:

The function in Java is as follows:

public static void printMessage(String lineOne, String lineTwo, int lines){

       for(int i = 1;i<=lines;i++){

           if(i%2 == 1){

               System.out.println(lineOne);

           }

           else{

               System.out.println(lineTwo);

           }

       }

   }

Explanation:

This defines the function

public static void printMessage(String lineOne, String lineTwo, int lines){

This iterates through the number of lines

       for(int i = 1;i<=lines;i++){

String lineOne is printed on odd lines i.e. 1,3,5....

      if(i%2 == 1){

               System.out.println(lineOne);

           }

String lineTwo is printed on even lines i.e. 2,4,6....

           else{

               System.out.println(lineTwo);

           }

       }

   }

To call the function from main, use:

printMessage("Hi", "Karel", 5);

You might be interested in
Write a program that would determine the day number in a non-leap year. For example, in a non-leap year, the day number for Dec
SOVA2 [1]

Answer:

In Python:

months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]

daymonths = [31,28,31,30,31,30,31,31,30,31,30,31]

day = int(input("Day: "))

month = input("Month: ")

ind = months.index(month)

   

numday = 0

for i in range(ind):

   numday+=daymonths[i]

numday+=day

print(numday)    

Explanation:

This initializes the months to a list

months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]

This initializes the corresponding days of each month to a list

daymonths = [31,28,31,30,31,30,31,31,30,31,30,31]

This gets the day from the user

day = int(input("Day: "))

This gets the month from the user

month = input("Month: ")

This gets the index of the month entered by the user

ind = months.index(month)

This initializes the sum of days to 0

numday = 0

This adds up the days of the months before the month entered by the user

<em>for i in range(ind):</em>

<em>    numday+=daymonths[i]</em>

This adds the day number to the sum of the months

numday+=day

This prints  the required number of days

print(numday)    

<em>Note that: Error checking is not done in this program</em>

7 0
3 years ago
The rangevalidator object on a web form has a type property for identifying the type of data for the range, such as ____.​
mojhsa [17]
<span>numbers,  dates, currency or strings - The range validator in a web form helps check whether the value entered in the field falls between the minimum and maximum values allowed in that field. For example if the type of data accepted  is of date type, then the rangevalidator checks whether the entered date falls within the given range. That means, month entered should be between 1 and 12, etc.</span>
8 0
3 years ago
The communications standard used to transfer pages on the Web is called _____.
andrezito [222]
Hypertext Transfer Protocol (HTTP)
5 0
3 years ago
What is common for all machines​
Fed [463]

Answer:

the question is a bit vague, but all machines exist to serve a purpose, or to do or accomplish a certain task.

6 0
3 years ago
Read 2 more answers
what identifies a cell or a range of cells on a worksheet, and tells excel where to look for values or data you to use in a form
zloy xaker [14]
I believe it is a cell Reference
6 0
2 years ago
Other questions:
  • Brian needs to assign a macro to a button on the ribbon. Where should he go to achieve this goal?
    13·2 answers
  • _______________creates new markets separate to the mainstream; markets that are unknowable at the time of the technology's conce
    8·1 answer
  • Consider a situation where we have a file shared between many people.  If one of the people tries editing the file, no other pe
    6·1 answer
  • Ano kaya ang nararamdaman mo at mangyari sayo kung tatlong araw ka nang hindi kumakain​
    6·1 answer
  • What is the definition of a digital signal?
    14·1 answer
  • BRAINLEST AND 20 POINTS! Most GUls provide all of the following except
    6·2 answers
  • A light rag is striking the surface of earth. Which factor would make the light ray more likely to be absorbed than reflected?
    8·1 answer
  • Many bookstores have closed since the rise of the Internet. What type of
    11·1 answer
  • You can merge the cells using the rowspan and colspan attribute of the tag <br> true or false​
    7·1 answer
  • Write code that declares a variable named minutes, which holds minutes worked on a job,
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!