Study Guide CSE 113LR
Popular in Intro To Computer Prog 1
Popular in Computer Science and Engineering
verified elite notetaker
This 0 page Study Guide was uploaded by Benny Ye on Wednesday November 11, 2015. The Study Guide belongs to CSE 113LR at University at Buffalo taught by Ramamurthy, B in Fall 2015. Since its upload, it has received 41 views. For similar materials see Intro To Computer Prog 1 in Computer Science and Engineering at University at Buffalo.
Reviews for Study Guide
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 11/11/15
Exam 2 The oop function causes draw to execute continuously If noLoop is called in setup the draw is only executed once In this example click the mouse to execute oop which will cause the draw the execute conUnuoqu In computer programming an array is a set of data elements stored under the same name Arrays can be created to hold any type of data and each element can be individually assigned and read There can be arrays of numbers characters sentences boolean values and so on The rst element is at position 0 the second is at 1 and so on The last position in the array is calculated by subtracting 1 from the array eg of Array int x 50 61 83 69 71 50 29 31 17 39 Each array can store only one type of data 1 While loop Write a while loop equivalent to the for loop code given below int abc 0 for int i 0 i lt 15 i i3 abc abc i println quot i quot i quot abc quot abc simply prints the values ofi and abc 2 while loop operation Trace the execution of the while loop in a table format Also show the output 3 switch statement Write the switch statement equivalent to the ifelse statement given below if letter a ca ca 1 else if letter e cece1 else if letter i cl ci1 else if letter o co co 1 else if letter u cu cu 1 else other 4 MousePressed event void setup size500500 noSmooth ll126 background102 void draw if mousePressed recwidth10height103535 else recwidth10height103535 Write a mousePressed method that draws 2 rectangles of size width10 and height10 at i the current mouse pressed location and ii the previous mouse pressed location 5 Array de nition int ex2Grades ex2Grades new int154 for int i 0 i lteX2Gradeslength i ex2Gradesi intrandom40101 int sum 0 for int j0 j lt ex2Gradeslength j sum sum ex2Gradesj oat avg sum ex2Gradeslength int hi maxex2Grades int 10 mineX2Grades println quot avg quot avg quotHi quot hi quot Low quot 10 intX 1 inty 1 Write Processing statements that i de nes an array called eXZGrades of exam2 grades ii creates 154 entries in the array for recording the grades iii write a quotforquot loop that initializes the array with random values between 40 and 100 inclusive 6 Array Access oat ex2Grades void setup size500500 for int i angx2 i lt datalength i oat eX maXeX2Grades0 ex2Grades1 ex2Grades2 eX eX 600 2000 oat eX eX2Grades0eX2Grades1 ex2Grades2 ex2Grades3 qz qz minquizGrades qz qz 1003000 oat ex eX2Grades0 eX2Grades1 eX2Grades2 eX2Grades3 lab lab minminex2Grades0ex2Grades1ex2Grades2eX2Grades3 lab lab ex2Grades4 lab lab 300 4000 oat percent ex printlnquothighest gradequot percent printInquotlowest gradequotpercent printInquotaverage gradequotpercent Write a Processing statements to i initialize a variable sum to 00 ii create a quotforquot loop to accumulate the sum in sum of all the grades in the above array and iii after the quotforquot loop and accumulating the sum determine the average of the exam2 grades in another variable angx1 Hint you can use arrayNamelength attribute Also write statements that will determine and print out i highest grade ii lowest grade and iii average grade 7 Function definition void setup size640 360 background51 noStrokeO noLoop coinStar int a 25 int b 10 int C 5 int cl 1 for aint a5 for bint b3 for cint c1 for dint d10 oat total abcd printlnquotTotal valuequot is 170 Write a function coinStar that inputs four parameters i number of quarters 25 cents ii number of dimes 10 cents iii number of nickels 5 cents and iv number of cents and computes and returns the total value of the input parameters in dollars For example if I have 5 quarters 3 dimes 1 nickel and 10 cents the total value returned in dollars is 170 8 Function call Assume I have 360 quarters 456 dimes 123 nickels and 1089 cents are in my piggy bank Invokecall this function coinStar to compute the value of the piggy bank and assign this value to myChange
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'