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 allows the user to navigate the lines of text in a file. The program should prompt the user for a filename
pickupchik [31]

Answer:

Explanation:

iname=input("Enter the file name: ")

inputfile=open(iname,'r')

lines=[]

for line in inputfile:

lines.append(line)

inputfile.close()

print("The file has ",len(lines)," lines")

while True:

linenumber=int(input("Enter the line number or 0 to quit: "))

if linenumber==0:

break

elif linenumber > len(lines):

print("Error: line number must be less than ", len(lines))

else:

print(linenumber, " : ", lines[linenumber - 1])

7 0
3 years ago
Using positive self talk is a great way to
lora16 [44]
Boost your self esteem and confidence.
7 0
2 years ago
Read 2 more answers
You are considering implementing a backup scheme for a server. After researching options, you decide on a method that does not r
Alecsey [184]

Answer:

C. A cold site is a leased facility that contains only electrical and communications wiring, air conditioning, plumbing, and raised flooring. No communications equipment, networking hardware, or computers are installed at a cold site until it is necessary to bring the site to full operation.

Explanation:

3 0
2 years ago
In multi-channel funnel reports, how are default conversions credited?
g100num [7]

The Multi-Channel Funnels reports are generated from conversion paths, the sequences of interactions (i.e., clicks/referrals from channels) that led up to each conversion and transaction. In the reports, channels are credited according to the roles they play in conversions—how often they assisted and/or completed sales and conversions.

6 0
2 years ago
WILL GIVE BRAINLIEST!!!!!!!
lisov135 [29]

Answer:

Ac

Explanation:

Ac maybe.Idk sorry.

8 0
3 years ago
Other questions:
  • By issuing concert tickets on the blockchain, fans can verify transfer of ownership from one digital wallet to another, rather t
    14·1 answer
  • What guidelines should you follow when adding graphics to your presentations?
    14·2 answers
  • What are 2 ways that technology can negatively impact the environment.
    8·2 answers
  • 1. Orthographic Drawings are used to express ideas that are more complicated. Explain the purpose of the different views and the
    7·1 answer
  • _______ can be used to prevent busy waiting when implementing a semaphore.
    15·1 answer
  • e do loop differs from the while loop in that a. the while loop will always execute the body of the loop at least once b. the do
    9·1 answer
  • Which of the following is an HTTP response status type?
    12·1 answer
  • What helps you evaluate websites for reliable information?
    15·2 answers
  • Describe how data is transmitted using half-duplex serial data transmission.
    9·1 answer
  • You have a Mobile Legends account???<br>Can I play with You???​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!