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
The Baltimore Sun reported on a study by Dr. Sara Harkness in which she compared the sleep patterns of 6-month-old infants in th
lawyer [7]

(a) The standard error of the mean (SEM) for the U.S. babies is 0.083.

(b) An approximate 95% confidence interval for the mean sleep time for 6-month-old babies in the United States is 12.8367< μ1< 13.163.

(c) An approximate 95% for the difference in average sleep time for 6-month-old Dutch and U.S. infants is −2.203< μ1 <μ2 < −1.7969.

What is standard error and how it is measured?

A statistical concept known as the standard error uses standard deviation to assess how accurately a sample distribution represents a population. The standard error of the mean describes the statistical variation between a sample mean and the population's actual mean.

According to the given information:

In United States:

Sample size $\boldsymbol{n}_1=\mathbf{3 6}$

Mean, $\bar{x}_1=13$

Standard deviation, $s_1=\mathbf{0 . 5}$

In Netherlands:

Sample size, $n_2=66$

Mean, $\bar{x}_2=15$

Standard deviation, $s_2=\mathbf{0 . 5}$

(a) For the newborns in the United States, the standard error of the mean (SEM) is determined as follows:

$$\begin{aligned}& S E\left(\bar{x}_1\right)=\frac{s_1}{\sqrt{n_1}} \\& S E\left(\bar{x}_1\right)=\frac{0.5}{\sqrt{36}} \\& S E\left(\bar{x}_1\right)=0.083\end{aligned}$$

(b) The following formula is used to determine the 95% confidence interval for the mean sleep time for babies aged 6 months in the United States:

$$\bar{x}_1 \pm z_{0.05 / 2} \times \sqrt{\frac{s_1^2}{n_1}}$$

$$\begin{aligned}& 13 \pm 1.96 \times \sqrt{\frac{0.5^2}{36}} \\& 12.8367 < \mu_1 < 13.163\end{aligned}$$

(c) The 95% difference in the amount of time newborns in the Netherlands and the United States spend sleeping on average is computed as follows:

$$\begin{aligned}& \bar{x}_1-\bar{x}_2 \pm z_{0.05 / 2} \times \sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}} \\& (13-15) \pm 1.96 \times \sqrt{\frac{0.5^2}{36}+\frac{0.5^2}{66}} \\& -2.203 < \mu_1 < \mu_2 < -1.7969\end{aligned}$$

To know more about standard error:

brainly.com/question/29363195

#SPJ4

8 0
1 year ago
Monster Collector
Lera25 [3.4K]

Answer:

In java:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int monsternum, usernum;

 int count = 0;

 Random rand = new Random();

 String [] monsters = {"wild pikamoo","wild bulbaroar"};

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

     monsternum = rand.nextInt(5);  

     System.out.print("A "+monsters[i]+" appears! Guess a number between 1 and 5: ");

     usernum = input.nextInt();

     if(monsternum == usernum){      count++;      System.out.println("Congratulations, you caught a "+monsters[i]+"!");  }

 else{      System.out.println("You almost had it, but the monster escaped.");  }

 

 }

 System.out.println("There are no more monsters to encounter!");

 System.out.println("You caught "+count+" monsters of 2");

 if(count!=2){      System.out.print("Keep training to be the very best!");  }

 else{      System.out.print("You're the monster collector master!");  }

}

}

Explanation:

This declares monster and user number as integers

 int monsternum, usernum;

Initialize count to 0

 int count = 0;

Call the random object

 Random rand = new Random();

Create a string array to save the monster names

 String [] monsters = {"wild pikamoo","wild bulbaroar"};

Iterate for the 2 monsters

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

Generate a monster number

     monsternum = rand.nextInt(5);  

Prompt the user to take a guess

     System.out.print("A "+monsters[i]+" appears! Guess a number between 1 and 5: ");

Get user guess

     usernum = input.nextInt();

If monster number and user guess are equal, congratulate the user and increase count by 1

<em>      if(monsternum == usernum){      count++;      System.out.println("Congratulations, you caught a "+monsters[i]+"!");  } </em>

If otherwise, prompt the user to keep trying

<em>  else{      System.out.println("You almost had it, but the monster escaped.");  }  </em>

<em>  } </em>

Print no monsters again

 System.out.println("There are no more monsters to encounter!");

Print number of monsters caught

 System.out.println("You caught "+count+" monsters of 2");

Print user score

<em>  if(count!=2){      System.out.print("Keep training to be the very best!");  } </em>

<em>  else{      System.out.print("You're the monster collector master!");  } </em>

5 0
3 years ago
Assume the name of your data frame is flavors_df. What code chunk lets you review the structure of the data frame?
Svetlanka [38]

Assuming the name of your data frame is flavors_df, the code chunk which will allow review of the structure of the data frame is colnames(flavors_df).

<h3>What is Code chunk?</h3>

This is referred to a a runable piece of R code and helps to reduce incidents of mismatch pertaining to the commentary in a paper and the results being discussed.

In the case of a data frame which is flavors_df, the appropriate code chunk is colnames(flavors_df) which allow for extensive review of the item with the barest minimal error which is why it was chosen as the most appropriate choice.

Read more about Code chunk here brainly.com/question/25525005

#SPJ1

4 0
1 year ago
Computer network reduces the cost. explain the statement with example.​
Crank

Answer:

Justify this statement with an example. Ans: Computer Network reduces expenses of an office because computer on a network share different hardware devices like printers, scanners, hard disk etc. And sharing those hardware devicAes will reduces the expense of an office.

Explanation:

Justify this statement with an example. Ans: Computer Network reduces expenses of an office because computer on a network share different hardware devices like printers, scanners, hard disk etc. And sharing those hardware devicAes will reduces the expense of an office.

3 0
3 years ago
Types of computer viruses<br>​
e-lub [12.9K]

Answer:anti various

Explanation:hope fully this will help u

5 0
3 years ago
Read 2 more answers
Other questions:
  • You are provisioning a server with eight-core 3 GHz CMP that can execute a workload with an overall CPI of 2.0 (assuming that L2
    5·1 answer
  • Which business filing process puts documents or data in the order by date? a. Linear
    7·1 answer
  • How do you ask brainy a question without it not liking the question and saying it hurts their feelings?
    14·1 answer
  • A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the clie
    11·1 answer
  • AYUDAAAA!!!!! URGENTE!!!!!!1<br> ¿para que sirve la "BIG DATA"?
    9·1 answer
  • True false.
    10·2 answers
  • write ms-dos command to list all the files and folders of EIGHT sub directory of C: drive in ascending order according to file n
    5·1 answer
  • Which of these commands is found by default on the quick access toolbar 1)save 2)new 3)open 4)print
    10·1 answer
  • mary needs to rename her report.txt file to final_report.txt. which command will allow her to do this?
    10·2 answers
  • List and describe four services that comprise IT infrastructure, beyond physical devices and software applications.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!