CIS 110 Fall 2015 Introduction to Computer Programming 7 Oct 2015 Makeup Midterm Exam

Similar documents
CIS 110 Fall 2015 Introduction to Computer Programming 6 Oct 2015 Midterm Exam Answer Key

CIS 110 Fall 2016 Introduction to Computer Programming 13 Oct 2016 Midterm Exam

CIS 110 Fall 2014 Introduction to Computer Programming 8 Oct 2014 Midterm Exam Name:

CIS 110 Introduction to Computer Programming 8 October 2013 Midterm

CIS 110 Introduction to Computer Programming Summer 2014 Midterm. Name:

CIS 110 Introduction to Computer Programming. 13 February 2013 Make-Up Midterm Midterm

CIS 110 Introduction to Computer Programming Spring 2016 Midterm

CIS 110 Introduction to Computer Programming Summer 2016 Midterm. Recitation # (e.g., 201):

CIS 110 Introduction to Computer Programming. 12 February 2013 Midterm

CIS Introduction to Computer Programming. 5 October 2012 Midterm

CIS 110 Introduction to Computer Programming Summer 2018 Midterm. Recitation ROOM :

CIS 110 Introduction to Computer Programming Fall 2017 Midterm. Recitation ROOM :

CIS Introduction to Computer Programming Spring Exam 1

CIS 110 Introduction to Computer Programming Summer 2017 Final. Recitation # (e.g., 201):

CIS 110 Introduction to Computer Programming Summer 2018 Final. Recitation # (e.g., 201):

CIS 110 Introduction to Computer Programming. 17 December 2012 Final Exam

CIS 110 Introduction to Computer Programming Summer 2014 Final. Name:

CIS 110 Introduction to Computer Programming Summer 2018 Final. Recitation # (e.g., 201):

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CIS 110 Introduction to Computer Programming. February 29, 2012 Midterm

CIS 371 Spring 2015 Computer Organization and Design 7 May 2015 Final Exam

CIS 110 Introduction to Computer Programming Summer 2016 Final. Recitation # (e.g., 201):

CIS Introduction to Computer Programming Spring Exam 2

CIS 110 Fall 2016 Introduction to Computer Programming 13 Oct 2016 Midterm Exam Answer Key

CIS 110 Introduction to Computer Programming. 7 May 2012 Final Exam

CIS 110 Introduction to Computer Programming Fall 2017 Final Midterm. Recitation Section# :

CIS 110 Introduction to Computer Programming Spring 2016 Final Exam

CIS 110 Introduction to Computer Programming Summer 2016 Final. Recitation # (e.g., 201):

CIS 110 Introduction to Computer Programming Fall 2017 Final Midterm. Recitation Section# :

CIS 110 Introduction To Computer Programming. November 21st, 2011 Exam 2

CIS 110 Spring 2013 Make-Up Midterm, 13 February 2013, Answer Key. Miscellaneous

CIS Fall 2012 Midterm, 7 June 2012, Answer Key. Miscellaneous

CIS 110 Introduction To Computer Programming. October 5th, 2011 Exam 1. Review problems

Instructor: Yu Wang 11/16/2012

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012

CIS 110 Introduction To Computer Programming. October 5th, 2011 Exam 1. Answer key for review problems

CS 1301 Exam 1 Fall 2010

SFWR ENG/COMP SCI 2S03 Principles of Programming SOLUTIONS

CSE 131 Introduction to Computer Science Fall Exam II

Question: Total Points: Score:

CS 1301 Exam 1 Fall 2010

CIS 110 Introduction to Computer Programming. 12 February 2013 Midterm. Answer Key

CIS 110 Introduction To Computer Programming. October 5th, 2011 Exam 1. Answer key

Exam Percentage: / 55 = %

5. PLEASE TAKE HOME the question bundle, but turn in 2 paper sheets: The scantron AND the paper where you wrote your programming question solution!

Prelim 1. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer

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

COS 126 General Computer Science Fall Written Exam 1

CIS 120 Midterm II November 8, Name (printed): Pennkey (login id):

CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am

CIS 120 Midterm II November 7, Name (printed): Pennkey (login id):

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2013

Learning Goals LG1: Implement the peer instruction process by A) clicking in on an answer B) discussing with your team C) coming to consensus and

PRACTICE MIDTERM EXAM #2

Instructions. This exam has 7 questions, worth 10 points each. You have 50 minutes.

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

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader

COMP 401 Midterm. Tuesday, Oct 18, pm-3:15pm. Instructions

Prelim 1, Solution. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer

Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination

CSE 131 Introduction to Computer Science Fall Final Exam

CSE 131 Introduction to Computer Science Fall Exam I

Prelim 1. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013

Question: Total Points: Score:

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

CS100J November 20, 2001

CS323: Data Structures and Algorithms Midterm Exam (October 17, 2016) Name:

CIS 110 Spring 2012 Final Exam, 7 May 2012, Answer Key. Miscellaneous

CSE 131 Introduction to Computer Science Fall Exam I

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013

CSE 142, Autumn 2008 Midterm Exam, Friday, October 31, 2008

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2012

Prelim 1. CS 2110, 13 March 2018, 5:30 PM Total Question Name Short answer

COS 126 General Computer Science Spring Written Exam 1

CS100M November 30, 2000

York University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes

CS 1301 Exam 3 Fall 2014

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

Computer Science II Data Structures

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

Prelim 1. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader

233 S. Wacker Drive, Suite 3600 Chicago, IL ext

COS 126 Midterm 1 Written Exam Fall 2011

COS 126 Midterm 1 Written Exam Fall 2012

CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012

CS100J February 13, 2001

EE 312 Fall 2017 Midterm 1 October 12, 2017

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

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

Question: Total Points: Score:

Problem Points Score Grader Total 75

Prelim 1. CS2110, October 2, 2014, 5:30 PM Extra Total Question TrueFalse Multiple Object Oriented

Computer Science II Lecture 1 Introduction and Background

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

CSE 131 Introduction to Computer Science Fall Exam II

EE 312 Fall 2018 Midterm 1 Version A October 10, 2018

CSE 142, Summer 2013 Midterm Exam, Friday, July 26, 2013

Spring 2013 COMP Midterm Exam Solutions March 07, 2013

Transcription:

CIS 110 Fall 2015 Introduction to Computer Programming 7 Oct 2015 Makeup Midterm Exam Name: Recitation # (e.g., 201): Pennkey (e.g., eeaton): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing this examination. Signature Date Instructions: Do not open this exam until told by the proctor. You will have exactly 110 minutes to finish it. Make sure your phone is turned OFF (not to vibrate!) before the exam starts. Food, gum, and drink are strictly forbidden. You may not use your phone or open your bag for any reason, including to retrieve or put away pens or pencils, until you have left the exam room. This exam is closed-book, closed-notes, and closed-computational devices. If you get stuck on a problem, it may be to your benefit to move on to another question and come back later. All code must be written out in proper Java format, including all curly braces and semicolons. Do not separate the pages. If a page becomes loose, reattach it with the provided staplers. Staple all scratch paper to your exam. Do not take any sheets of paper with you. If you require extra paper, please use the backs of the exam pages or the extra pages provided at the end of the exam. Clearly indicate on the question page where the graders can find the remainder of your work (e.g., back of page or on extra sheet ). Use a pencil, or blue or black pen to complete the exam. If you have any questions, raise your hand and a proctor will come to answer them. When you turn in your exam, you may be required to show ID. If you forgot to bring your ID, talk to an exam proctor immediately. We wish you the best of luck. Have a great Fall break! Scores: [For instructor use only] Question 0 1 pts Question 1 9 pts Question 2 10 pts Question 3 5 pts Question 4 15 pts Question 5 8 pts Question 6 20 pts Total: 68 pts

CIS 110 Fall 2015 Midterm Score: Page: 1 0.) The Easy One (1 point total) Check to make certain that your exam has all 7 pages (excluding the cover sheet). Write your name, recitation number, and PennKey (username) on the front of the exam. Sign the certification that you comply with the Penn Academic Integrity Code. 1.) Value Judgments (9 points total) Fill in the data type and final value of the variable a. (Assume a is always declared with the most appropriate data type.) Write CE as the data type if the statements will cause compiler error, or RE if they will cause a run-time error. Give the reason for the error in the third column. The first row has been filled in for you. Type of a a = 2; int 2 String s = "110"; a = Double.parseDouble(s) - 110; Value of a/error explanation a = Integer.parseInt(3); a = 5 % -4; double[] b = new double[5]; a = b.length(); a = "A" == "A"; String s = "110"; a = s + 110; a = 'A' == 'A'; a = 4.0 + 7 / 2; a = ((int) 4.0) / 8.0;

CIS 110 Fall 2015 Midterm Score: Page: 2 2.) Loopy Loop-de-Loops (10 points total) Consider the following program: public class Amusement { public static void main(string[] args) { int foo = 100; for (int i = 5; i < 25; i+= 5) { System.out.println(foo / i + "?"); for (int j = 1; j < 5; j++) { System.out.print(args[j] + "!"); Assume you run the program at the DrJava interactions pane using the command below, then answer the questions: java Amusement Loop-de-loop roller coasters are fun 2.1) (2 points) How many question marks (?) will get printed? 2.2) (2 points) How many exclamation points (!) will get printed? 2.3) (6 points) What does the program print?

CIS 110 Fall 2015 Midterm Score: Page: 3 3.) Changing Gears (5 points total) Study the following program, then answer the questions. public class VWDiesel { public static void main(string[] args) { int smog = Integer.parseInt(args[0]); int emissions = 0; int catalyzer = 1; while (smog!= 0) { emissions = emissions + catalyzer * (smog % 10); smog = smog / 10; catalyzer *= 10; System.out.println(emissions); 3.1) (2 points) What gets printed when you run java VWDiesel 143? 3.2) (3 points) In 15 words or less, explain in simple English what the VWDiesel program does.

CIS 110 Fall 2015 Midterm Score: Page: 4 4.) So the pope opens a restaurant... (15 points total) Although it wasn t widely publicized, the pope opened a trendy new restaurant in Old City during his recent visit. The city did publish a short press release about the event, but the Secret Service classified much of the pope s long-planned remarks by garbling the text. Fortunately, an enterprising CIS 110 TA discovered a recursive program that can ungarble them among Edward Snowden s NSA leaks. Unfortunately, the leaked code is missing certain key elements. Complete the program below, then tell us what the pope said at his new restaurant s opening. 4.1) (11 points) Complete the program: public class PopeUngarbler { public static ungarble( code, start, end) { if (end < start) ""; // base case int mid = (start + end) / 2; char a = code. (mid); // mid-point // character at mid-point // recursively ungarble return a + (code, start, mid - 1) + (code, mid + 1, end); public static main( ) { String a = "EEHSECTESAK"; String b = "EAHEVN"; String c = "TIRM-ED"; System.out.println("Welcome to " + ungarble(a, 0, a.length() - 1) + " " + ungarble(b, 0, b.length() - 1) + ". " + "I will be your " + ungarble(c, 0, c.length() - 1) + "."); 4.2) (4 points) What did the pope say at the restaurant opening?

CIS 110 Fall 2015 Midterm Score: Page: 5 5.) The Trump Exam Question (8 points total) Real-estate, gambling, reality TV mogul, and Wharton-alumnus Donald Trump is famous for his business empire of branded skyscrapers, resorts, casinos, and presidential campaigns. A fan of poker and blackjack, Trump is rumored to despise the card game bridge because it values No Trump bids above all others. We are proud to offer you his latest and potentially most profitable ever luxury, Trump-branded venture: the first in what promises to be a long line of lucrative Trump Exam Questions. public static int trump(int tower, int tajmahal) { if (tajmahal == 0) return 1; else if (tajmahal % 2 == 0) return trump(tower * tower, tajmahal / 2); else return tower * trump(tower, tajmahal - 1); 5.1) (2 points) What is the value returned by trump(2, 1)? 5.2) (2 points) What is the value returned by trump(2, 4)? 5.3) (2 points) What is the value returned by trump(3, 3)? 5.4) (2 points) What was the name of this function before Trump purchased the naming rights? (We will accept any reasonable answer.)

CIS 110 Fall 2015 Midterm Score: Page: 6 6.) Coding (20 points total) Write a function risingsequence that takes an array of integers, and returns the length of the longest sequence of consecutive, rising numbers in the array. For example, the longest sequence of consecutive rising numbers in the array {3, 45, 6, 12, 18, 21, 21, 19, 41, 2 is {6, 12, 18, 21, so risingsequence would return 4 for this array. If the array is null, return 0. As long as the array has at least one element, the longest sequence of consecutive rising numbers should be at least 1. Do not write the class structure, only write the function itself. Make a reasonable effort to indent your code, but it does not have to be perfect. Comments will not be graded, so you do not have to include any at all. However you are welcome to include them writing comments may well help you work out the solution.

CIS 110 Fall 2015 Midterm Score: Page: 7 [ Scrap Paper: This Page Intentionally Blank ]