Computers and Technology

Convert each of the following for loops into an equivalent while loop. (You might need to rename some variables for the code to compile, since all four parts a-d are in the same scope.) // a.

System. out. println("a.");
int max = 5;
for (int n = 1; n <= max; n++) {

System. out. println(n);

}

System. out. println();

// b.

System. out. println("b.");

int total = 25;

for (int number = 1; number <= (total / 2); number++) {

total = total - number;

System. out. println(total + " " + number);

}

System. out. println();

// c.

System. out. println("c.");

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

for (int j = 1; j <= 3; j++) {

for (int k = 1; k <= 4; k++) {

System. out. print("*");

}

System. out. print("!");

}

System. out. println();

}

System. out. println();

// d.

System. out. println("d.");

int number = 4;

for (int count = 1; count <= number; count++) {

System. out. println(number);

number = number / 2;

}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:20, LuchaPug
Write the pseudocode for the following: a function called fahrenheittocelsius that accepts a real fahrenheit temperature, performs the conversion, and returns the real celsius temperature. a function called celsiustofahrenheit that accepts a real celsius temperature, performs the conversion, and returns the real fahrenheit temperature. a main module that asks user to enter a fahrenheit temperature, calls the fahrenheittocelsius function, and displays the celsius temperature with a user-friendly message. it then asks the user to enter a celsius temperature, calls the celsiustofahrenheit function, and displays the fahrenheit temperature with a user-friendly message.
Answers: 1
image
Computers and Technology, 22.06.2019 15:30, tfornwalt4390
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
image
Computers and Technology, 23.06.2019 04:31, Remba
Q14 what is most important for you to choose before you build a network? a. private network b. nos c. network media d. network protocol e. directory service
Answers: 1
image
Computers and Technology, 24.06.2019 13:30, yola32
What is the most important for you to choose before you build a network?
Answers: 1
Do you know the correct answer?
Convert each of the following for loops into an equivalent while loop. (You might need to rename som...

Questions in other subjects:

Konu
Biology, 17.04.2020 04:32