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
Basile [38]
3 years ago
11

How I to turn this ''loop while'' in ''loop for''? var i = 0; while (i < 20) { var lineY = 20 + (i * 20); line(0, lineY, 400,

lineY); i++; }
Computers and Technology
1 answer:
Fudgin [204]3 years ago
5 0

Answer:

for(i = 0; i<20;i++){

lineY = 20 + (i * 20);

line(0, lineY, 400, lineY) }

Explanation:

First declare and initialize the variable i. You have not specified the data type of i so if the data type of i is integer i.e. int then you should declare i variable in the for loop as for(int i = 0; i<20;i++)

So the given while loop has a variable i which is initialized to 0. Then while(i<20) means that while loop executes until the value of i exceeds 20. If this while condition is true then the two statements inside its body will execute. The two statements are: lineY = 20 + (i * 20);

line(0, lineY, 400, lineY);

The value of i ins incremented after each iteration i.e. i++

So while loop has the following syntax"

1) initialization;  ---->  i = 0

2) while(condition) {  ----> i<20

3) loop body ----->  lineY = 20 + (i * 20); line(0, lineY, 400, lineY);

4) increment or decrement loop variable  } ----> i++

For loop has the following syntax:

for( initialization of loop variable ; condition; decrement/increment loop variable)  {

loop body }

Here:

initialization  ---->  i = 0

condition        ----> i<20

loop body     -----> lineY = 20 + (i * 20); line(0, lineY, 400, lineY);

increment or decrement loop variable  ---->  i++

You might be interested in
Đất trồng có tầm quan trọng như thế nào đối với đời sống của cây:
Ainat [17]

Answer:

C

Explanation:

5 0
3 years ago
Which of the following is an example of a soft skill?
Lady bird [3.3K]
Answer is (B)

Helping a customer by answering a question whether on the phone of face to face is an example of soft skills. Such skills are developed through Effective communication, better listening skills, positivity, assertiveness, empathy, conflict resolution, and depersonalization. 
<span>Basically, if you have these skills when handling a customer, what they will remember is what they felt about your service.</span>

 
8 0
3 years ago
Read 2 more answers
Laura is confused with the spelling of the word pronunciation. She types the word pronunciation. Which feature of the auto corre
larisa [96]
I think this answer is b
5 0
3 years ago
Read 2 more answers
Which of the following applies to patents?
babymother [125]
They protect the rights of the property owner. I watch a lot of shark tank and I believe that’s right
3 0
2 years ago
The remove() method in the Queue interface ________. Group of answer choices retrieves, but does not remove, the head of this qu
salantis [7]
<h2>Question:</h2>

The remove() method in the Queue interface ________.

A. retrieves, but does not remove, the head of this queue, returning null if this queue is empty

B. retrieves and removes the head of this queue, or null if this queue is empty

 

C. retrieves, but does not remove, the head of this queue, throwing an exception if this queue is empty

D. retrieves and removes the head of this queue and throws an exception if this queue is empty

<h2>Answer:</h2>

D. retrieves and removes the head of this queue and throws an exception if this queue is empty

<h2>Explanation:</h2>

In Java, the Queue interface is found in the java.util package and inherits from the Collection interface. It is used to store elements which are processed in the order in which they are inserted. This means that the first element will be processed first.

The Queue interface has many methods. Some of them are;

i. add(): allows elements to be added to the queue.

ii. remove(): retrieves and removes elements from the head of the queue. The head of the queue points to the first element of the queue. If the queue is empty, the remove() method throws an exception called the <em>NoSuchElementException</em>

<em />

iii. poll(): retrieves and removes the element at the head of the queue. Unlike the remove() method, if the queue is empty, a <em>null </em>is returned.

iv. peek(): retrieves but does not remove the element at the head of the queue. Just like the poll() method, a <em>null</em> is returned if the queue is empty.

7 0
3 years ago
Other questions:
  • software that instructs the computer how to run applications and controls the display/keyboard is known as the
    11·1 answer
  • One of the benefits of conditional ____________________ is that it helps you analyze data by highlighting significant trends in
    6·1 answer
  • If you have a long title for a table and need it to span several cells, you can use A. Merge Cells. B. Split Cells. C. Insert Co
    5·1 answer
  • Ok so another weird question! So if you know what google drive is and how to upload a video why does it keep adding hours! it ke
    11·1 answer
  • A researcher wants to do a web-based survey of college students to collect information about their sexual behavior and drug use.
    7·1 answer
  • A Unit of information containing the objects position, rotation, and scale values is called:
    13·1 answer
  • A friend was just promoted to a new job that requires part-time travel, and he has also been promised a new laptop after his fir
    10·1 answer
  • Is this website real? Or is it a scam?
    11·1 answer
  • What is a narrative?
    7·2 answers
  • What practice makes it virtually impossible to figure out the geographic location of a company?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!