CS 155 Exam 2 Spring 2015

Similar documents
Question: Total Points: Score:

Section 003 Fall CS 170 Exam 1. Name (print): Instructions:

Section 003 Fall CS 170 Exam 2. Name (print): Instructions:

Question: Total Points: Score:

CS 170 Exam 1. Version: B Fall Name (as on OPUS):

Instructor: Yu Wang 11/16/2012

CS 170 Exam 1. Version: C Fall Name (as on OPUS):

Question: Total Points: Score:

Question: Total Points: Score:

Place your name tag here

Question: Total Points: Score:

CS 170 Section 3, Spring 2015 Programming in Java Midterm Exam 1. Name (print):

Question: Total Points: Score:

CS 170 Exam 2. Version: A Spring Name (as in OPUS) (print): Instructions:

CS 190 Exam 2 Fall 2014

Question: Total Points: Score:

CS 110 Exam 2 Fall 2011

Question: Total Points: Score:

CS 170 Section 3, Spring 2015 Programming in Java Midterm Exam 1. Name (print):

CS 110 Exam 2 Spring 2011

CS 1301 Exam 1 Fall 2011

Question: Total Points: Score:

Question: Total Points: Score:

Exam Percentage: / 55 = %

Section 002 Spring CS 170 Exam 1. Name (print): Instructions:

Question: Total Points: Score:

Section 004 Spring CS 170 Exam 1. Name (print): Instructions:

CS 170 Exam 2. Version: A Spring Name (as in OPUS) (print): Instructions:

CS 170 Exam 2. Version: A Fall Name (as in OPUS) (print): Instructions:

CS 170 Exam 2. Section 004 Fall Name (print): Instructions:

Question: Total Points: Score:

CS 1301 Exam 1 Fall 2010

Question: Total Points: Score:

Question: Total Points: Score:

CS 1301 Exam 1 Fall 2010

Your (printed!) Name: CS 1803 Exam 3. Grading TA / Section: Monday, Nov. 22th, 2010

CS 1301 Exam 1 Spring 2014

CS 1301 Exam 3 Spring 2014

CS 190 Exam 1 Fall 2010

CS 1301 Exam 1 Spring 2014

CS 1301 Exam 2 A Fall 2015

CS 2316 Exam 4 Fall 2011

CS 1301 Exam 1 Spring 2011

CS Exam 2 - Spring 2010

CS 1301 Exam 1 Fall 2013

CS 1803 Fall 2010 Exam 1

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 3 Fall 2014

CS 2316 Exam 1 Spring 2014

CS 2316 Exam 4 Spring 2013

CS 2316 Exam 1 Spring 2013

CS 1301 Exam 2 A Fall 2015

CS 2316 Exam 4 Fall 2012

CS 1803 Fall 2010 Exam 1

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 1 Fall 2013

CS170 (005): Introduction to Computer Science Exam 2

CS Name : Grading TA:

Question Possible Points Earned Points Graded By GUI 22 SQL 24 XML 20 Multiple Choice 14 Total Points 80

CS 1301 Exam 2 Fall 2013

CS Exam 3 - Spring 2010

CS 1301 Exam 2 Fall 2014

CS 1301 Exam 3 A Spring 2015

CS 110 Exam 1 Fall 2011

CS 1301 Exam 2 Spring 2014

CS 2316 Exam 4 Fall 2011

CS 1301 Exam 2 Fall 2010

CS 1301 Exam 3 Spring 2012

CS Exam 2 Name: Your Grading TA: This exam has 7 pages including the title page. Please check to make sure all pages are included.

CS 2316 Exam 3 Spring 2013

CS 2316 Exam 4 Fall 2012

CS 1301 Exam 1 Spring 2015

VBA Collections A Group of Similar Objects that Share Common Properties, Methods and

CS 2316 Exam 4 Fall 2014

CS Exam 3 - Spring 2010

CS 1316 Exam 1 Summer 2009

Pivot Tables, Lookup Tables and Scenarios

CS 2316 Exam 4 Spring 2012

DOWNLOAD PDF MICROSOFT EXCEL ALL FORMULAS LIST WITH EXAMPLES

2. INTRODUCTORY EXCEL

CS 2316 Exam 2 Summer 2011

CS 111X - Fall Test 1

CS 2316 Exam 3 Fall 2011

CS 1301 Exam 1 Fall 2009

1 Introduction to Using Excel Spreadsheets

Create your first workbook

The Excel worksheet contains 16,384 rows that extend down the worksheet, numbered 1 through

Learn Ninja-Like Spreadsheet Skills with LESSON 9. Math, Step by Step

CS 2316 Exam 3 Fall 2012

CS 1301 Exam 3 Fall 2010

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

Excel Functions & Tables

This exam has 10 pages including the title page. Please check to make sure all pages are included.

EDIT202 Spreadsheet Lab Prep Sheet

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9

Microsoft Excel 2010 Handout

CS 1301 Exam 1 Answers Fall 2009

THE FORMULAS TAB, CELL REFERENCING,THE VIEW TAB & WORKBOOK SECURITY THE FORMULAS TAB, CELL REFERENCING, THE VIEW TAB & WORKBOOK SECURITY OBJECTIVES

CS 1301 Post Exam 3 Practice Spring 2016

Advanced Financial Modeling Macros. EduPristine

Transcription:

CS 155 Exam 2 Spring 2015 Name (print): Instructions: Keep your eyes on your own paper, and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than the professor/proctor for ANY reason in ANY language in ANY manner. This is exam is closed book, closed notes, no calculator, and no computer. Turn all mobile devices off and put them away now. You cannot have them on your desk. Write neatly and clearly. What I cannot read, I will assume to be incorrect. Stop writing immediately when told to do so at the end of the exam. I will take 5 points off your exam if I have to tell you multiple times to do so. Academic misconduct will not be tolerated and will be referred immediately to the Emory Honor Council. Penalties for misconduct will be a zero on this exam, an F grade in the course, and/or other disciplinary action that may be applied by the Emory Honor Council. Time: This exam has 9 questions on 10 pages including the title page. Please check to make sure all pages are included. You will have 75 minutes to complete this exam. I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Emory community. I have also read and understand the requirements and policies outlined above. Signature: Question: 1 2 3 4 5 6 7 8 9 Total Points: 10 10 8 5 12 5 9 6 10 75 Score: 1

1. (10 points) Excel Vocabulary Define 5 of the 6 terms below. You do not need a formal definition, just a good description. Limit your answers to about 20 words per term. You may use an example if it would be helpful. Clearly mark the term you do not wish to include; otherwise, I will discard the last term. (a) comment Solution: p238: lines of code which are meant to provide information about the code. In Excel, comments begin with a. These lines are ignored by the compiler. (b) Monte Carlo simulation Solution: p202: A simulation in which values for uncertain variables are randomly generated over and over to simulate a model. (c) high level language (d) macro Solution: p241: computer programming language with strict syntax rules featuring symbols, numbers, alphabetic characters, etc. Must be translated to machine language for computer to execute. Solution: p223: automated series of Excel steps which can be executed through a single command (e) variable Solution: p247: symbolic name which refers to a storage location where data is stored during program execution (f) comma-separated values Solution: p163: A file in which fields are separated by a comma. Data can be imported into Excel as Excel looks for commas and makes columns based on the placement of the commas 2

2. Short answer. Answer the following questions. Be brief! (a) (2 points) Explain how Excel utilizes the variant data type. Solution: P249. Variant is the default datatype which Excel assigns in the absence of any other specification. Takes up more space and is slower to use. (b) (2 points) Explain why you should encapsulate your macro code in a module rather than attaching it to a specific sheet in a workbook. Solution: Makes it accessible from any worksheet rather than simply from one worksheet. (c) (2 points) Explain the difference between visible variables and invisible variables. Solution: Visible variables are values store in a cell on a visible worksheet. Invisible variables are symbolic names which refer to memory/values. (d) (2 points) Using valid VBA code, list two different ways to reference cell A1 and set its value to 14. Solution: See pg. 248. Any of the following would work: Range("A1").Value = 14 Cells(1,1).Value = 14 Cells(1,"A").Value = 14 Cells("1", "A").Value = 14 [A1:A1].Value = 14 [A1].Value = 14 (e) (2 points) Select all of the following which are legal variable names in VBA. A. dim B. price C. 3rdsale D. office_num E. price_in_us$ F. first name G. address2 Solution: dim is a keyword, 3rdsale starts with a number, price_in_us$ contains a symbol and first name contains a space. 3

3. Evaluate the following formulas. If any formula would result in an error, you may simply write error. (a) (2 points) =MEDIAN(A1:A9) (b) (2 points) =MODE(A1:A9) (c) (2 points) =AVERAGE(A1:A9) (a) 25 (b) 20 (c) 30 (d) (2 points) You are told that the formula =PERCENTILE(A1:A9, 0.8) returns 40. In your own words, explain this result in the context of the numbers in A1:A9. Solution: This tells us that, given the values in A1:A9, the 80% cutoff is 40. Thus, 2 values in the list of numbers are in the 80th percentile (and higher): 55 and 60. In other words, the other 7 numbers are below the 80th percentile for this list of values. 4

4. Consider the following piece of a spreadsheet which is being used to calculate a commission percentage and year-end bonus for salespeople based on the number of sales. Evaluate the following formulas. If any expression would lead to an error, you may simply write Error. (a) (1 point) Evaluate the following formula: =VLOOKUP(B5, E2:G6, 2, TRUE) Solution: 5% or.05 (b) (1 point) Evaluate the following formula: =VLOOKUP(B5, E2:G6, 2, FALSE) Solution: #N/A error (c) (1 point) Evaluate the following formula: =VLOOKUP(B5, E2:G6, 3, TRUE) Solution: 750 (d) (2 points) Write a formula in C1 which could be copied and pasted into the rest of column C to calculate the percentage commission due to each salesperson. Solution: =VLOOKUP(B2,$E$2:$G$6,2, TRUE) Some students chose to do a nested IF statement: =IF(B2<$E$3, $F$2, IF(B2<$E$4, $F$3, IF(B2<$E$5, $F$4, IF(B2<$E$6, $F$5, $F$6))))) Scoring: +1 arguments/logic correct +1 absolute addressing 5

5. Random Number Generation (a) (1 point) What is the minimum value returned by the formula =2*RANDBETWEEN(7, 13)+1? (b) (1 point) What is the maximum value returned by the formula =2*RANDBETWEEN(7, 13)+1? (c) (3 points) List all the possible values returned by the formula =2*RANDBETWEEN(7, 13)+1? (a) 15 (b) 27 Solution: 15, 17, 19, 21, 23, 25, 27 (d) (3 points) List all possible values returned by the formula: =INT(RAND()*4) Solution: 0, 1, 2, 3 (e) (2 points) Without using the RANDBETWEEN function, write a formula which would generate a random whole (non-decimal) number between 1 and 15: Solution: =INT(RAND()*15)+1 (f) (2 points) Write a formula which would generate a random even whole (nondecimal) number between 2 and 24 (inclusive). Solution: =2*RANDBETWEEN(1, 12) or =INT(RAND()*12+1)*2 Note that =INT(RAND() * 13) * 2 doesn t work because it will also generate 0. 6

6. (5 points) In a workbook, you are given the following module and spreadsheet: Private A as Integer Private B as Integer Sub Example1() A = 4 Cells(1,"A") = A Cells(1,"B") = B Sub Example2() A = Cells(1,"A").Value C = Cells(1,"B").Value + 7 Cells(1,"C").Value = C Mod A Sub Example3() A = Cells(1,"A").Value B = Cells(1,"B").Value B = B + A + 1.6 Cells(2,"B").Value = A Cells(2,"A").Value = B Module1 Initial State of Spreadsheet The sub-procedures Example3, Example2, and Example1 are executed in that order on the spreadsheet with the initial values shown on the above right. Fill in the following cell values in the spreadsheet after the code has executed. If you think a statement would result in an error, you may simply write error in the cell. Be explicit in your answer (for example, there is a difference between 0, error, and a blank cell). Solution: This question was unintentionally tricky due to B being declared as an integer, but adding 1.6 to that in Example3. Because of the datatype switching (which you hadn t really been exposed to), I accepted 11, 11.6 or 12 as the values of B1 and A2. The image above is how Excel evaluates it. 7

7. (9 points) In a workbook, you are given the following two modules: Module1 and Module2: Public A As Integer Private B As Integer Sub Example1() A = 100 B = A + 1 Sub Example2() Cells(1,"A").Value = A Cells(1,"B").Value = B Sub Example3() Dim C As Integer C = A + B Cells(1,"C").Value = C Sub Example4() Cells(2,"A").Value = A Cells(2,"B").Value = B Cells(2,"C").Value = C Sub Example5() Cells(3,"A").Value = A Cells(3,"B").Value = B Cells(3,"C").Value = C Module1 Module2 Assume that the sub-procedures Example1, Example2, Example3, Example4, and Example5 are executed in that order. Fill in the following cell values in the spreadsheet after the code has executed. If you think a statement would result in an error, you may simply write error in the cell. Be explicit in your answer (for example, there is a difference between 0, error, and a blank cell). 8

8. (6 points) An integer (whole) number is given in cell A1 which represents a number of inches. Write a sub-procedure called InchesToFeet which computes the feet and inches and puts them into cells B1 and C1 respectively. There are 12 inches in 1 foot. For example, if A1 contains the number 22, after executing your code, B1 should contain 1 and C1 should contain 10 since 22 inches is 1 foot, 10 inches. Solution: Sub FeetToInches() Cells(1,"B").Value = Cells(1,"A").Value \ 12 Cells(1,"C").Value = Cells(1,"A").Value Mod 12 Scoring: +1 subprocedure header/ender +1 read value from A1 +1 calculate feet correctly +1 calculate inches correctly +1 display calculations +1 syntax/variable declarations (if used) Common errors: using / instead of \ for calculations when working with integer data types. Reversing RHS and LHS of assignment operator. Ex: Cells(1,"A").Value = A. This assigns the value of A to the visible cell A1. What you needed to do was A = Cells(1,"A").Value which assigns the value in A1 to the variable A. 9

9. (10 points) Assume that a Super Bowl advertisement cost $150 for 1 second of viewing time. Moreover, you can only buy ads in multiples of 30 seconds (ie, ads that are 30, 60, 90... seconds) long. Write a subprocedure named SuperBowlAd which reads an integer from cell A1. This number represents the number of dollars you have to spend. Your sub-procedure should calculate the number of seconds of airtime you can buy with your money given the above restrictions and puts the calculation into B1. You may assume the value in A1 is always a number greater than or equal to 0. You may also assume that all quantities can be represented by the integer datatype (in other words,youdonotneedtoworryaboutanumberbeingtoolargefortheintegerdatatype). For example, if the value in A1 is 4500, your sub-procedure should put 30 into B1 since you could buy 30 seconds of airtime. If the value in A1 is 6000, your sub-procedure should put 30 into B1 since you could buy 40 seconds of airtime, but you can only buy in 30 second multiples. Solution: Sub SuperBowlAd() Dim A as Integer A = Cells(1,"A").Value A = A \ 150 A = A \ 30 A = A * 30 Cells(1,"B").Value = A +1 subprocedure header/ender +1 reads values from a1 +1 puts final calculation into b1 +2 value divided by 150 +2 value rounded down (either use \ operator or int function w/ datatypes) +3 only calculates multiples of 30 10