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

Similar documents
CSE 142, Autumn 2010 Midterm Exam, Friday, November 5, 2010

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

CSE 142, Summer 2010 Midterm Exam, Friday, July 30, 2010

CSE 142, Autumn 2011 Midterm Exam: Friday, November 4, 2011

CSE 142, Autumn 2007 Midterm Exam, Friday, November 2, 2007

CSE 142, Spring 2009, Sample Final Exam #2. Good luck!

CSE142 Sample Midterm Spring Name UW NetId (e.g. whitab) Section (e.g., AA) TA

CSE142 Sample Midterm, Winter 2018

CSE 142 Sample Midterm Exam #2

CSE 143, Winter 2010 Midterm Exam Wednesday February 17, 2010

CSE 142, Autumn 2010 Final Exam Wednesday, December 15, Name:

Building Java Programs A Back to Basics Approach 4th Edition Reges TEST BANK Full download at:

CSE 142, Spring 2010 Final Exam Wednesday, June 9, Name: Student ID #: Rules:

CSE 142, Spring 2009, Final Exam

CSE 142 Sample Midterm Exam #3

CSE142 Sample Midterm Autumn 2018

Midterm Review Session

Sample Midterm Exam #2

CSE 143, Winter 2009 Final Exam Thursday, March 19, 2009

CSE 143, Winter 2010 Final Exam Thursday, March 18, 2010

CSE 143: Computer Programming II Spring 2015 Midterm Exam Solutions

CSE 142, Winter 2007 Final Exam. Name:

CSE 142 Sample Midterm Exam #3

1. An operation in which an overall value is computed incrementally, often using a loop.

CSE142 Midterm Autumn This exam is divided into eight questions with the following points: # Problem Area Points Score

CSE 143: Computer Programming II Spring 2015 Final Exam Solutions

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

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

CSE 303, Spring 2009 Final Exam Wednesday, June 10, 2009

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

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

CSE143 Midterm Summer Name of Student: Section (e.g., AA): Student Number:

CSE 143: Computer Programming II Autumn Sample Solutions

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009

CSCI 1226 A Test #1. Wednesday, 10 October, 2018 Name: Student #: General Instructions Read and follow all directions carefully.

Some Practice Midterm Problems

CSE 114 Midterm 1. Please leave one seat between yourself and each of your neighbors.

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

AP COMPUTER SCIENCE A

Problem Description Earned Max 1 CSS 20 2 PHP 20 3 SQL 10 TOTAL Total Points 50

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam

King Saud University College of Computer and Information Sciences Computer Science Department

I. True/False: (2 points each)

Name CIS 201 Midterm II: Chapters 1-8

5) (4 points) What is the value of the boolean variable equals after the following statement?

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

NoSuchElementException 5. Name of the Exception that occurs when you try to read past the end of the input data in a file.

CIS 110 Introduction To Computer Programming. December 19th, 2011 Final. Answer key

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

CSE 373, Winter 2013 Final Exam, Tuesday, March 19, Good luck! You can do it!

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

CSCI 1226 Sample Midterm Exam

CSE 154, Autumn 2012 Final Exam, Thursday, December 13, 2012

CSE143 Summer 2008 Final Exam Part B KEY August 22, 2008

1 Short Answer (10 Points Each)

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b))

CONCORDIA UNIVERSITY Summer 2005 Comp 248 /1 Section AA Introduction to Programming Final Examination/A

Final Exam. COMP Summer I June 26, points

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz

CS 112 Introduction to Programming

Building Java Programs

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

CS141 Programming Assignment #6

Problem Grade Total

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

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

Problem Description Earned Max 1 PHP 25 2 JavaScript / DOM 25 3 Regular Expressions 25 TOTAL Total Points 100. Good luck! You can do it!

CIS Introduction to Computer Programming. 5 October 2012 Midterm

CS 101 Exam 2 Spring Id Name

CS 305j Midterm 2 Fall 2006

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

Building Java Programs

CMPS 12A - Winter 2002 Midterm 2 March 5, Name: ID:

CONDITIONAL EXECUTION

b. Suppose you enter input from the console, when you run the program. What is the output?

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

COMP-202: Foundations of Programming. Lecture 8: for Loops, Nested Loops and Arrays Jackie Cheung, Winter 2016

Problem Points Score Grader Total 75

CSE Fall 2015 Section 002 Exam 2, Time: 80 mins

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue

JAVA OPERATORS GENERAL

McGill University School of Computer Science COMP-202A Introduction to Computing 1

CS 177 Spring 2010 Exam I

Problem Description Earned Max 1 PHP 25 2 JavaScript/DOM 25 3 Regular Expressions 25 4 SQL 25 TOTAL Total Points 100

CS 113 PRACTICE FINAL

CIS 110 Introduction To Computer Programming. December 19th, 2011 Final. Answer key for review problems

CIS October 19, 2017

CSE 154: Web Programming Autumn 2018

Selenium Class 9 - Java Operators

University of Palestine. Mid Exam Total Grade: 100

Building Java Programs Chapter 2

University of Massachusetts Amherst, Electrical and Computer Engineering

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

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010

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

Menu Driven Systems. While loops, menus and the switch statement. Mairead Meagher Dr. Siobhán Drohan. Produced by:

Computer Programming, I. Laboratory Manual. Final Exam Solution

Transcription:

CSE 142, Summer 2013 Midterm Exam, Friday, July 26, 2013 Name: Section: TA: Student ID #: You have 60 minutes to complete this exam. You may receive a deduction if you keep working after the instructor calls for papers. This exam is closed-book/notes. You may not use any calculators, cell phones, Google Glass, or other computing devices. Code will be graded on proper behavior/output and not on style, unless otherwise indicated. Do not abbreviate code, such as "ditto" marks or dot-dot-dot... marks. The only abbreviations that are allowed for this exam are: S.o.p for System.out.print, S.o.pln for System.out.println, S.o.pf for System.out.printf, and A, S, and N for Always, Sometimes, and Never on problem 5. You do not need to write import statements in your code. If you enter the room, you must turn in an exam before leaving the room. You must show your Student ID to a TA or instructor for your exam to be accepted. Good luck! Score summary: (for grader only) Problem Description Earned Max 1 Expressions 10 2 Parameter Mystery 12 3 If/Else Simulation 12 4 While Loop Simulation 12 5 Assertions 15 6 Programming 15 7 Programming 15 8 Programming 9 TOTAL Total Points 100 1 of 8

1. Expressions (10 pts) For each expression at left, indicate its value in the right column. List a value of appropriate type and capitalization. e.g., 7 for an int, 7.0 for a double, "hello" for a String, true or false for a boolean. Expression 12 / 3 + 5 + 3 * -2 2 + 2 + "(2 + 2)" + 2 + 2 13 / 2-38 / 5 / 2.0 + (15 / 10.0) 3.0 / 1.5 6 / 4 10.0 / 2 / 2 20 % 6 + 6 % 7 + 1 % 6 Value 2. Parameter Mystery (12 pts) At the bottom of the page, write the output produced by the following program, as it would appear on the console. public class ParameterMystery { public static void main(string[] args) { int a = 2; int b = 9; int c = 4; int three = a; int one = b + 1; axiom(a, b, c); axiom(c, three, 10); axiom(b + c, one + three, a + one); a++; b = 0; axiom(three, 2, one); public static void axiom(int c, int b, int a) { System.out.println(b + " + " + a + " = " + c); 2 of 8

3. If/Else Simulation (12 points) For each call below to the following method, write the output that is produced, as it would appear on the console: public static void ifelsemystery(int x, int y) { if (x == y) { x = x + 11; else if (x > 2 * y) { x = 0; if (x == 0 y > x) { x = x + 2; y = y + 2; else { y = y - 1; System.out.println(x + " " + y); Method Call ifelsemystery(5, 5); ifelsemystery(18, 4); ifelsemystery(3, 6); ifelsemystery(0, 0); Output 3 of 8

4. While Loop Simulation (12 points) For each call below to the following method, write the output that is produced, as it would appear on the console: public static void whilemystery(int x, int y) { while (x > 0 && y > 0) { y = y - x; x--; System.out.print(y + " "); System.out.println(y); Method Call whilemystery(5, 7); whilemystery(4, 20); whilemystery(10, 40); whilemystery(5, 15); Output 4 of 8

5. Assertions (15 points) For each of the five points labeled by comments, identify each of the assertions in the table below as either being always true, never true, or sometimes true / sometimes false. (You may abbreviate them as A, N, or S.) public static int stuff(random r, int m) { int c = 0; int t = 0; int d = r.nextint(m); // Point A while (c <= 3) { // Point B d = r.nextint(6) + 1; if (d <= m) { c++; // Point C else { c = 0; // Point D t++; // Point E return t; c > 3 d <= m c == 0 Point A Point B Point C Point D Point E 5 of 8

6. Programming (15 pts) Write a static method called printlistmin that takes a Random object and an integer n as a parameter and produces two lines of output, where the first line contains n randomly generated two-digit numbers, separated by a comma and a space, and the second line contains a phrase indicating the minimum value from the previous line. The method should use the Random object to select numbers in the range of 10 to 99 (inclusive) where each number is equally likely to be chosen. For example, given the following lines of code: Random r = new Random(); printlistmin(r, 3); printlistmin(r, 5); You would expect output like the following: 46, 32, 77 min was 32 88, 47, 54, 62, 19 min was 19 You may assume that the value passed to your method is greater than or equal to 1. You are to exactly reproduce the format of these logs, though due to the randomness, your method is unlikely to produce the same values. Write your solution to printlistmin below. 6 of 8

7. Programming (15 pts) Write a static method called randomart that takes two integers as parameters, size and frequency, and prints a size by size grid where each character in the grid is selected randomly between an asterisk (*) and a plus sign (+), and returns the number of asterisks printed in the artwork. The plus sign should be frequency times as likely to be printed as the asterisk. Thus, if frequency is 1, the plus sign should be equally likely to be printed as the asterisk, and if frequency is 4, the plus sign should be 4 times more likely to be printed than the asterisk. You may assume that the values passed to your method will both be integers greater than or equal to 1. Your method should construct a Random object to produce the randomness. Several example calls are shown below (note that, because the method uses randomness, repeated calls will likely not produce the same output). Call randomart(4, 2); randomart(7, 5); randomart(1, 4); Example Output ++++ *+** +++* +++++++ *++++++ +++++++ + *++* +**+*+* *+++*++ ++*++*+ +++++** Return value 6 11 0 Write your solution to randomart below. 7 of 8

8. Programming (9 pts) Write a static method called countparityswitches that takes an integer value as a parameter and returns the number of parity (even or odd) switches between the digits (that is, the number of pairs of consecutive digits where one is even and the other is odd, in either order). For example, a call of countparityswitches(36487) would return 2 because the parity switches between the 3 and the 6 and again between the 8 and the 7. If the value passed contains only one digit, or only even or odd digits, the method should return 0. You may assume that the value passed to the method will be greater than or equal to 1. Below are the results of some sample calls to countparityswitches. Method Call Return Value countparityswitches(5); 0 countparityswitches(800); 0 countparityswitches(12345); 4 countparityswitches(14); 1 countparityswitches(75930); 1 Write your solution to countparityswitches below. 8 of 8