4. Create a loop (for/while) that draws squares that are 5 pixels wide and 5 pixels...
Fantastic news! We've Found the answer you've been seeking!
Question:
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/05/6643618060d06_904664361802cd9b.jpg)
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/05/664361816c67a_905664361813cb2f.jpg)
Transcribed Image Text:
4. Create a loop (for/while) that draws squares that are 5 pixels wide and 5 pixels tall near the top of the screen, across the entire width of the screen. (6 marks) What would you change about your code if we only wanted the squares on the first half of the screen? 5. Create a loop (for/while) that draws circles that are 10 pixels wide and 10 pixels from the top left corner to the bottom right corner of the screen. (6 marks) What would you change about your code if we only wanted the circles to go from the top left corner to the middle of the screen (diagonally)? In-Class Assignment: While/For Loops 1. What is wrong with this code? Explain and fix the code! for (var s = 10; s <400;){ rect(s,10,5,5); } 2. Given the following code: var x = 10; while(x <100){ println(x); x = x*2; } Fill in the table below: Value of x Output 3. What would the output of the following code be? Explain! for (var a = 3; a < 10000; a = a*a){ println(a); } What would the output be if a = 5? T: /22 (2 marks) (4 marks) (4 marks) 4. Create a loop (for/while) that draws squares that are 5 pixels wide and 5 pixels tall near the top of the screen, across the entire width of the screen. (6 marks) What would you change about your code if we only wanted the squares on the first half of the screen? 5. Create a loop (for/while) that draws circles that are 10 pixels wide and 10 pixels from the top left corner to the bottom right corner of the screen. (6 marks) What would you change about your code if we only wanted the circles to go from the top left corner to the middle of the screen (diagonally)? In-Class Assignment: While/For Loops 1. What is wrong with this code? Explain and fix the code! for (var s = 10; s <400;){ rect(s,10,5,5); } 2. Given the following code: var x = 10; while(x <100){ println(x); x = x*2; } Fill in the table below: Value of x Output 3. What would the output of the following code be? Explain! for (var a = 3; a < 10000; a = a*a){ println(a); } What would the output be if a = 5? T: /22 (2 marks) (4 marks) (4 marks)
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
If I were to have$210,000in student loans.My bank charges 4%APR(compounded monthly).Suppose I can only afford to pay$1,000per month towards my student loans,calculate the number of months it will...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Read the following article and answer the questions below: Building Competitive Advantage Through People Magazine: Winter 2002Research Feature January 15, 2002 Reading Time: 23 min Christopher A....
-
The Louisiana Grill The Louisiana Grill (TLG) is a restaurant in Toronto. TLG is a regional restaurant created and operated by Alex Ven- tresca, a former football player from New Orleans. The company...
-
A capacitor (5.70F) is connected in a series arrangement with a second capacitor (2.30F) and a 12-V battery. (a) How much charge is stored on each capacitor? (b) What is the voltage drop across each...
-
Does it appear that the pattern of AIDS cases in Santa Clara County corresponds to the distribution of ethnic groups in this county? Why or why not? The following data are real. The cumulative number...
-
Find someone whose vision has made a difference in their life. Ask them to share their story.
-
Grear Tire Company has produced a new tire with an estimated mean lifetime mileage of 36,500 miles. Management also believes that the standard deviation is 5000 miles and that tire mileage is...
-
10 arctan (2+r) dr 10 arctan (3+r)dr 10 arct arctan(3+r)da arctan r dr lim 100 7 arctan | 5 | 9
-
2. Let X= 1405 Suppose that the demand for the monopolist's product is given by q = X p and the total cost of production is c ( q ) = 10 q . (a) Suppose a price ceiling of $30 is imposed. What is the...
-
Fill in the Blank. The stiffness matrix is positive definite only if the system is _________.
-
Fill in the Blank. The motion of a two-degree-of-freedom system is described by two __________ coordinates.
-
Fill in the Blank. Maxwell's reciprocity theorem states that the influence coefficients are _________.
-
The value of purchase by every sixth person entering a departmental store. Determine whether the data set is a population or a sample. Explain your reasoning.
-
The number of distinct natural frequencies for an \(n\)-degree-of-freedom system can be a. 1 b. \(\infty\) c. \(n\)
-
Lee Ltd makes a range of products all of which follow a similar production process and have the same cost structure. The products are made in batches that are started at the beginning of the month...
-
San Carlos Bank and Trust Company uses a credit-scoring system to evaluate most consumer loans that amount to more than $2,500. The key factors used in its scoring system are found at the conclusion...
-
Many organizations talk about the need to be collaborative and work as a team. What changes would be necessary in an organizations human resources systems to reinforce teamwork?
-
How would you respond to a professor who was initially very inclusive and encouraging but later became more demanding?
-
What are the activities or interests that take up most of your time?
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App