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
alexgriva [62]
3 years ago
10

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;

}
Computers and Technology
1 answer:
MAVERICK [17]3 years ago
5 0

Answer:

~CaptnCoderYankee

Don't forget to award brainlyest if I got it right!

Download txt
You might be interested in
What action should you take if you become aware that sensitive compartmented information has been compromised
irina [24]

The sensitive compartmented information can not be compromised and in case found with the incident it must be reported to the security officer.

<h3>What is Sensitive Compartmented Information?</h3>

The sensitive compartmented information is given as the sensitive information to the United States gathered with the source of the intelligence and the analytical process.

The information has been sensitive and was considered not to be compromised. In case the information is found to be compromised, the security officer of the information must be contacted to check into the details.

Learn more about sensitive information, here:

brainly.com/question/25948574

#SPJ1

5 0
2 years ago
Write a Java class with the following methods: getArray(int numStrings) is an instance method that takes command line input (use
mezya [45]

Answer:

Follows are the code to this question:

import java.util.*;//import packae for user-input  

public class Main//defining a class Main

{

public String[] getArray(int numString)//defining a method getArray

{

String[] name=new String[numString];//defining array of String values

Scanner in = new Scanner(System.in);// creating scanner class object for input values from user-end

for(int i=0;i<numString;i++)//defining for loop for input multiple values

{

System.out.print("Enter String Value :");//print message

name[i]=in.nextLine();//input values

}

return name;//return array values

}

public String getLongestString(String[] sArray)//defining a method getLongestString

{

int m=0,mi=0; //defining integer variables

for(int i=0;i<sArray.length;i++)//defining for loop for check the longest value in array

{

if(m<sArray[i].length())//defining if block that checks m varaible value greater then sArray length  

{

m=sArray[i].length();//use m to hold sArray length

mi=i;//use max_index to hold i that is loop value

}

}

return sArray[mi];//return Longest value

}

public static void main(String[] args)//defining main method

{

Main s=new Main();//Creating object of main class    

String[] n;//defining string variable n  

n=s.getArray(5);//use n varaible to call getArray method and store its value

System.out.println("Longest value is: "+s.getLongestString(n));//use print method to call getLongestString method

}

}

Output:

please find attached file.

Explanation:

In the given java program code, inside the main class two method that is "getArray and getLongestString", is defined, in which the "getArray" method uses an integer variable in its parameter and inside the method, an array is defined that use a  scanner class for input array value.

  • In the "getLongestString" pass as a parameter and inside the method, two integer variable "m and mi" is defined that use in the loop to return the longest string value.
  • In the class main method is to define that creates a class object and call the above method and use the print method to return its value.  

4 0
3 years ago
What is green computing in non-technical term?​
DochEvi [55]

Answer:

Green computing is also known as green information technology (green IT)

4 0
3 years ago
Which of the following is the largest disadvantage of wind power?
nydimaria [60]
The answer is     C.wind machines only generate electricity when wind is blowing
3 0
3 years ago
Read 2 more answers
Traditionally, remote administrative access on routers was configured using Telnet on TCP port 23. However, Telnet was developed
FinnZ [79.3K]

<u>Explanation</u>:

It is an all-too-often used technology today in connecting several computers together via a network.

Routing simple terms means the action of selecting the path taken by the traffic of data in a network of computers. The routing systems involve the use of both wireless and cable based architectures. Some common example of routing systems includes:

  1. Dynamic Routing
  2. Static routing
  3. Default Routing
5 0
3 years ago
Other questions:
  • When the minnesota timberwolves encouraged facebook fans to post a great shot of a dunk onto its pinterest page for a chance to
    6·1 answer
  • This was not a "true" operating system, but rather an operating environment.
    5·1 answer
  • In scratch the location of a sprite is defined by what?
    10·1 answer
  • CRM systems provide an organization with an important element: all employees of the company who directly or indirectly serve a c
    9·1 answer
  • If a user inserts a piece of clip art over some text but does not want the art to block the text, the user should select
    14·2 answers
  • What does a page break do?
    13·1 answer
  • 1. What are you going to do if someone ask for your personal information online?​
    12·2 answers
  • What is one disadvantage of transmitting personal data using digital signals?
    15·2 answers
  • Game Design!
    10·2 answers
  • What does playstation network is currently undergoing maintenance?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!