Western Oregon University Page 1 of 2 CS-161 Pre-Lab #7 General At the top of the every document that you create (word processing files or source files) include: /** * Description of the class or document. * * @author YOUR NAME * @version CS161 Lab #, mm/dd/yyyy (replace with the last edit date) */ The primary purpose of each pre-lab is to help you prepare to be an active participant during the lab sessions, and to be ready to discuss and understand the material presented in lectures. This is why late submissions are NOT accepted as that defeats the primary purpose of the prelab. However, as these are done prior to class discussions, PRE-LABS are not graded on correctness of your answers, but on whether you have shown a reasonable attempt at investigating and trying to solve the problem. Please feel free to bring up questions during your lecture class about material in the prelabs that you don’t understand or where not able to complete correctly. We will devote some of the lecture time to answering these questions. Prelabs are part of a flipped classroom model where you are responsible for studying and learning the majority of the easier to understand material so that we can focus on the more difficult concepts during the lecture time that is available. Prelabs are NOT collaborative assignments; they are to be done individually. Academic plagiarism policies apply and are enforced. Concepts The purpose of this pre-lab is to expand your experience with writing Java source code and to prepare you for lab 7. Background Read through the end of Chapter #5 in your text. Use the online tutorials (refer to the class web site) to get any further clarifications that you may need after reading the chapter material. Assignment Instructions Using the CODE PAD to experiment with Arrays: Enter EACH of the following lines into the CODE PAD of BlueJ (you may need to create a project first, then under the view menu select “Show code pad”): Cutting and pasting from a Word processor will probably result in errors, so please just type the lines into codepad. Make sure you look at the result of each operation and understand why the result is what it is! Cut and past screen captures to document your work on these. 1) int[] myNums = {2, 4, 6, 8, 10}; 2) myNums[0] 3) myNums[3] 4) for (int temp : myNums) { System.out.println(temp); } Western Oregon University Page 2 of 2 CS-161 Pre-Lab #7 5) myNums[0] = 3 6) myNums[0] 7) myNums.length 8) myNums[ myNums.length – 1] 9) int i = 2; 10) myNums[ i] 11) myNums[ ++i] 12) i 13) myNums[ myNums[0]] 14) for (int j = 0; j < myNums.length; j++) { myNums[ j ] = j * j; } 15) for (int j = 0; j < myNums.length; j++) { System.out.println( myNums[ j]); } Write at least 3 questions about concepts you do not understand after completing this lab and bring them to class on Monday. ALSO REMEMBER THAT THERE IS A READING ASSIGNMENT DUE THIS WEEK!!! Submission Instructions Submit in this prelab via Moodle using the “PreLab #” link. Your assignment MUST be uploaded by the assignment due date and time (see Moodle for the time), no exceptions or extensions of time are given. Partial credit is given, so submit however much of the prelab that you have completed by the due time otherwise both the prelab and lab will receive a 0 grade for the week. Moodle will automatically close the link at that time. It is highly recommend you do not wait until the very last minute to submit your work. ALL PRE-LABS are to be submitted as a SINGLE document in PDF format. Most modern word processors can now generate a PDF file or you can download free utilities to do the conversion (CutePDF for pc’s). Any submissions in any other format will not be graded and will not receive credit. Type your answers when appropriate, or if diagrams are needed you may scan them or take a picture and then paste the picture into the document. For coding questions, take one or more screen shots that show the code that you modified or created; and take screen shots of the run of your programs showing the outputs. Paste anything into your document that demonstrates your investigation and work on each of the questions. In your submission, please mark each of your answers/investigation with the question number clearly shown. Order the questions/answers in your PDF document in the same order that they are assigned in the prelab. If you do not do this, you may not get credit for some of your work.