CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam

Size: px
Start display at page:

Download "CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam"

Transcription

1 Seat Number Name CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam This is a closed book exam. Answer all of the questions on the question paper in the space provided. If you need additional space, you can ask for more paper. This is a 50-minute exam. 1) (10 points, 1 point each) Match each of the terms on the left by choosing the upper case letter of the best answer on the right and putting it next to the lower case letter in the space provided. a. iterative enhancement b. procedural decomposition c. exception d. precedence e. flow of control f. postcondition g. precondition h. public class i. public static final j. public static void A. a runtime error B. used for declaring class constants C. the order in which operators are evaluated in an expression D. the order in which statements are executed E. used to begin a class F. must be true before a method starts G. writing a program in stages H. guaranteed to be true when a method ends I. separation of tasks into subtasks J. used to begin a method 2) (10 points) Consider a method that has three parameters, an initial loan balance, an interest rate, and a monthly payment. It returns the number of months needed to pay back the loan. You do not have to write this method. a) What are the preconditions for this method? b) What are the postconditions for this method?

2 3) (10 points) Suppose that x is an double variable that has been declared and initialized. Write a code segment for each of the following: a) Print the message The value is OK if x is greater than 0 and less than 1, and print the message x is not OK otherwise. b) Print the message The value is not OK if it is not true that x is greater than 0 and less than 1.

3 4) (15 points) The following program has at least 7 errors. For each error, circle where the error occurs, label the circle with a letter: A, B, C, etc. Then for each letter, indicate how you would fix the error. import java.util.*; public class FindAverage { public static void main(string args) { console = new Scanner(); int sum; for (int i=0; i<10; i++) { System.out.println("Enter an integer"); next = console.next(); sum = sum + next; System.out.println("The average is " + sum/10);

4 5) (10 points) What is printed by executing mystery1(5) for the following: public static void mystery1(int x) { if (x < 3) { mystery2(3*x); System.out.print(23); else { System.out.print(36); mystery2(2*x); mystery2(5*x); public static void mystery2(int x) { if (x < 12) System.out.print(x); else System.out.print(x-1); 6) (10 points) Write a method that takes a Scanner as a parameter. It prompts the user to enter 10 numbers and returns the number of times a negative number was entered.

5 7) (10 points) a) Write a method called writechars which takes 2 parameters, a char and an int which prints the first parameter the number of times given by the second parameter. Do not print a new line. b) Use writechars to write the method drawbox that will print a box with a given width and height. If the parameters are 10 and 5, it will draw a box similar to the one on the right. ********** * * * * * * **********

6 8) (15 points) The table below represents the cost per pound of cashew nuts, which depends on the number of pounds purchased. Suppose that the variable, x contains the number of pounds purchased. Write a code segment that prints the total cost of the purchase in dollars. Number of pounds purchased Cost per pound under 5 $ at least 5, but less than 10 $ at least 10, but less than 50 $ 8.50 at least 50 $ 7.29

7 9) (5 points) Write the method countstring that takes has 2 String parameters. It returns the number of times the second string appears in the first string.

8 10) (5 points) In Australia, dates are often represented with the day of the month first, followed by the month name, followed by the year. For example, today would be represented by 29 October Write a method that takes a single String parameter in this format and returns the String representing the month. You may assume that a single blank separates the fields. Choose an appropriate name for the method.

Final. Your Name CS Fall 2014 December 13, points total Your Instructor and Section

Final. Your Name CS Fall 2014 December 13, points total Your Instructor and Section Final Your Name CS 1063 - Fall 2014 December 13, 2014 100 points total Your Instructor and Section I. (10 points, 1 point each) Match each of the terms on the left by choosing the upper case letter of

More information

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

1. An operation in which an overall value is computed incrementally, often using a loop. Practice Exam 2 Part I: Vocabulary (10 points) Write the terms defined by the statements below. 1. An operation in which an overall value is computed incrementally, often using a loop. 2. The < (less than)

More information

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam Page 0 German University in Cairo April 6, 2017 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam Bar Code

More information

Midterm Review Session

Midterm Review Session Midterm Review Session Programming Problems For more practice: http://webster.cs.washington.edu:8080/practiceit/ Copyright 2009 by Pearson Education Midterm Logistics Bring your UW Student ID card!! Will

More information

Topic 12 more if/else, cumulative algorithms, printf

Topic 12 more if/else, cumulative algorithms, printf Topic 12 more if/else, cumulative algorithms, printf "We flew down weekly to meet with IBM, but they thought the way to measure software was the amount of code we wrote, when really the better the software,

More information

This exam is open book. Each question is worth 3 points.

This exam is open book. Each question is worth 3 points. This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or

More information

CEN 414 Java Programming

CEN 414 Java Programming CEN 414 Java Programming Instructor: H. Esin ÜNAL SPRING 2017 Slides are modified from original slides of Y. Daniel Liang WEEK 2 ELEMENTARY PROGRAMMING 2 Computing the Area of a Circle public class ComputeArea

More information

Name CIS 201 Midterm II: Chapters 1-8

Name CIS 201 Midterm II: Chapters 1-8 Name CIS 201 Midterm II: Chapters 1-8 December 15, 2010 Directions: This is a closed book, closed notes midterm. Place your answers in the space provided. The point value for each question is indicated.

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 5 Lecture 5-4: do/while loops, assertions reading: 5.1, 5.5 1 The do/while loop do/while loop: Performs its test at the end of each repetition. Guarantees that the loop's

More information

CSE 142 Sample Midterm Exam #3

CSE 142 Sample Midterm Exam #3 CSE 142 Sample Midterm Exam #3 1. Expressions (10 points) For each expression in the left-hand column, indicate its value in the right-hand column. Be sure to list a constant of appropriate type (e.g.,

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 5 Lecture 5-4: do/while loops, assertions reading: 5.1, 5.5 1 The do/while loop do/while loop: Performs its test at the end of each repetition. Guarantees that the loop's

More information

Over and Over Again GEEN163

Over and Over Again GEEN163 Over and Over Again GEEN163 There is no harm in repeating a good thing. Plato Homework A programming assignment has been posted on Blackboard You have to convert three flowcharts into programs Upload the

More information

CSE142 Sample Midterm, Winter 2018

CSE142 Sample Midterm, Winter 2018 CSE142 Sample Midterm, Winter 2018 1. Expressions, 10 points. For each expression in the left-hand column, indicate its value in the right-hand column. Be sure to list a constant of appropriate type (e.g.,

More information

1 Short Answer (10 Points Each)

1 Short Answer (10 Points Each) 1 Short Answer (10 Points Each) 1. Write a for loop that will calculate a factorial. Assume that the value n has been input by the user and have the loop create n! and store it in the variable fact. Recall

More information

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

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

More information

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

NoSuchElementException 5. Name of the Exception that occurs when you try to read past the end of the input data in a file. CSC116 Practice Exam 2 - KEY Part I: Vocabulary (10 points) Write the terms defined by the statements below. Cumulative Algorithm 1. An operation in which an overall value is computed incrementally, often

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming Summary of Methods; User Input using Scanner Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu Admin

More information

Ch. 6. User-Defined Methods

Ch. 6. User-Defined Methods Ch. 6 User-Defined Methods Func5onal Abstrac5on Func5onal regarding func5ons/methods Abstrac5on solving a problem in a crea5ve way Stepwise refinement breaking down large problems into small problems The

More information

Chapter 2: Basic Elements of Java

Chapter 2: Basic Elements of Java Chapter 2: Basic Elements of Java TRUE/FALSE 1. The pair of characters // is used for single line comments. ANS: T PTS: 1 REF: 29 2. The == characters are a special symbol in Java. ANS: T PTS: 1 REF: 30

More information

CSE 143 Sample Midterm Exam #8 (12wi)

CSE 143 Sample Midterm Exam #8 (12wi) 1. ArrayList Mystery Consider the following method: CSE 143 Sample Midterm Exam #8 (12wi) public static void mystery(arraylist list) { for (int index = 0; index < list.size(); index++) { int elementvalue

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us From this site you can click on the COSC-236

More information

CSE 142 Sample Midterm Exam #2

CSE 142 Sample Midterm Exam #2 CSE 142 Sample Midterm Exam #2 1. Expressions For each expression in the left-hand column, indicate its value in the right-hand column. Be sure to list a constant of appropriate type (e.g., 7.0 rather

More information

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

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012 CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012 Name: This exam consists of 7 problems on the following 6 pages. You may use your single- side hand- written 8 ½ x 11 note sheet during the

More information

Full file at

Full file at Chapter 1 1. a. False; b. False; c. True; d. False; e. False; f; True; g. True; h. False; i. False; j. True; k. False; l. True. 2. Keyboard and mouse. 3. Monitor and printer. 4. Because programs and data

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

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

Building Java Programs A Back to Basics Approach 4th Edition Reges TEST BANK Full download at: Building Java Programs A Back to Basics Approach 4th Edition Reges TEST BANK Full download at: Building Java Programs A Back to Basics Approach 4th Edition Reges SOLUTIONS MANUAL https://testbankreal.com/download/building-java-programs-a-back-to-basicsapproach-4th-edition-reges-test-bank/

More information

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

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below. C212 Early Evaluation Exam Mon Feb 10 2014 Name: Please provide brief (common sense) justifications with your answers below. 1. What is the type (and value) of this expression: 5 * (7 + 4 / 2) 2. What

More information

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

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks: كلية الحاسبات وتقنية المعلوما Exam 2 Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: November 22, 2015 Student Name: Student ID: Total Marks: 40 Obtained Marks: Instructions: Do not open this

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming Program Analysis Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu Admin q PS5 Walkthrough Thursday

More information

CSE 20. SAMPLE FINAL Version A Time: 180 minutes. The following precedence table is provided for your use:

CSE 20. SAMPLE FINAL Version A Time: 180 minutes. The following precedence table is provided for your use: CSE 20 SAMPLE FINAL Version A Time: 180 minutes Name The following precedence table is provided for your use: Precedence of Operators ( ) - (unary),!, ++, -- *, /, % +, - (binary) = = =,!= &&

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 4 Lecture 4-2: Advanced if/else; Cumulative sum; reading: 4.2, 4.4-4.5 2 Advanced if/else reading: 4.4-4.5 Factoring if/else code factoring: Extracting common/redundant code.

More information

CSE 143, Winter 2009 Sample Midterm Exam #2

CSE 143, Winter 2009 Sample Midterm Exam #2 CSE 143, Winter 2009 Sample Midterm Exam #2 1. Stacks and Queues. Write a method interleave that accepts a queue of integers as a parameter and rearranges the elements by alternating the elements from

More information

Topic 12 more if/else, cumulative algorithms, printf

Topic 12 more if/else, cumulative algorithms, printf Topic 12 more if/else, cumulative algorithms, printf "We flew down weekly to meet with IBM, but they thought the way to measure software was the amount of code we wrote, when really the better the software,

More information

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 Question One: Choose the correct answer and write it on the external answer booklet. 1. Java is. a. case

More information

COSC 1010 Introduction to Computer Programming

COSC 1010 Introduction to Computer Programming COSC 1010 Introduction to Computer Programming Exam 1, Spring 2016 Exam Duration: Sixty (60) Minutes The exam has three parts: Multiple Choice (17 points), Short Answer (30 points) and Programming (53

More information

CSE 142 Sample Midterm Exam #3

CSE 142 Sample Midterm Exam #3 CSE 142 Sample Midterm Exam #3 1. Expressions For each expression in the left-hand column, indicate its value in the right-hand column. Be sure to list a constant of appropriate type (e.g., 7.0 rather

More information

CS 101 Spring 2007 Midterm 2 Name: ID:

CS 101 Spring 2007 Midterm 2 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

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

CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012 CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012 Name: This exam consists of 6 problems on the following 7 pages. You may use your two-sided hand-written 8 ½ x 11 note sheet during the exam.

More information

AP Programming - Chapter 17 Lecture page 1 of 5

AP Programming - Chapter 17 Lecture page 1 of 5 page 1 of 5 Recursion I. Thinking Recursively In this chapter we look at another method of repetition, recursion. A recursive computation solves a problem by calling itself to solve a smaller piece of

More information

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

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz The in-class quiz is intended to give you a taste of the midterm, give you some early feedback about

More information

Programming (Ü) Flow of Control. Solutions

Programming (Ü) Flow of Control. Solutions Programming (Ü) Solutions Exercise 1 Write an expression that evaluates to true if and only if the value of the integer variable x is equal to zero. Exercise 1 Solution x == 0 Exercise 2 Write an expression

More information

CS 1083 Introduction to Programming I for Computer Scientists Sample Final Questions

CS 1083 Introduction to Programming I for Computer Scientists Sample Final Questions CS 1083 Introduction to Programming I for Computer Scientists Sample Final Questions 1. What is printed by the following program? Show all your work for partial credit. public class SampleFinalq1 { public

More information

Array. Array Declaration:

Array. Array Declaration: Array Arrays are continuous memory locations having fixed size. Where we require storing multiple data elements under single name, there we can use arrays. Arrays are homogenous in nature. It means and

More information

Possible Exam Questions

Possible Exam Questions Name: Class: Date: Here are all the questions from all your previous tests. Your exam will be made up of some of these questions. Use these to study from. Remember - all the answers are contained in your

More information

CS 113 MIDTERM EXAM 2 SPRING 2013

CS 113 MIDTERM EXAM 2 SPRING 2013 CS 113 MIDTERM EXAM 2 SPRING 2013 There are 18 questions on this test. The value of each question is: 1-15 multiple choice (3 pts) 17 coding problem (15 pts) 16, 18 coding problems (20 pts) You may get

More information

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

CS 170 Exam 2. Version: A Spring Name (as in OPUS) (print): Instructions: CS 170 Exam 2 Version: A Spring 2016 Name (as in OPUS) (print): Section: Seat Assignment: Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do

More information

Object Oriented Programming. Java-Lecture 1

Object Oriented Programming. Java-Lecture 1 Object Oriented Programming Java-Lecture 1 Standard output System.out is known as the standard output object Methods to display text onto the standard output System.out.print prints text onto the screen

More information

Tutorial # 4. Q1. Evaluate the logical (Boolean) expression in the following exercise

Tutorial # 4. Q1. Evaluate the logical (Boolean) expression in the following exercise Tutorial # 4 Q1. Evaluate the logical (Boolean) expression in the following exercise 1 int num1 = 3, num2 = 2; (num1 > num2) 2 double hours = 12.8; (hours > 40.2) 3 int funny = 7; (funny!= 1) 4 double

More information

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly

More information

Computational Expression

Computational Expression Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name

More information

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 7, Name:

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 7, Name: CSC 1051 Algorithms and Data Structures I Midterm Examination October 7, 2013 Name: Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the spaces

More information

Handout 4 Conditionals. Boolean Expressions.

Handout 4 Conditionals. Boolean Expressions. Handout 4 cs180 - Programming Fundamentals Fall 17 Page 1 of 8 Handout 4 Conditionals. Boolean Expressions. Example Problem. Write a program that will calculate and print bills for the city power company.

More information

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer Computing Science 114 Solutions to Midterm Examination Tuesday October 19, 2004 INSTRUCTOR: I E LEONARD TIME: 50 MINUTES In Questions 1 20, Circle EXACTLY ONE choice as the best answer 1 [2 pts] What company

More information

There are four variables declared. They are named pearprice, pearcost, pearsales, and profit.

There are four variables declared. They are named pearprice, pearcost, pearsales, and profit. Activity 1 int pearprice = 3; int pearcost = 1; int pearsales = 17; int profit = pearsales * (pearprice - pearcost); System.out.print("The profit is "); System.out.println(profit); and was given these

More information

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

CS 170 Exam 2. Version: A Fall Name (as in OPUS) (print): Instructions: CS 170 Exam 2 Version: A Fall 2015 Name (as in OPUS) (print): Section: Seat Assignment: Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do

More information

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Computer Programming, I. Laboratory Manual. Experiment #3. Selections Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3

More information

CS 101 Fall 2006 Midterm 3 Name: ID:

CS 101 Fall 2006 Midterm 3 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

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

CSE 142, Autumn 2008 Midterm Exam, Friday, October 31, 2008 CSE 142, Autumn 2008 Midterm Exam, Friday, October 31, 2008 Name: Section: Student ID #: TA: You have 50 minutes to complete this exam. You may receive a deduction if you keep working after the instructor

More information

CS3360 Design and Implementation of Programming Languages Final Exam May 16, pm to 12:45pm (2 hour and 40 minutes) NAME:

CS3360 Design and Implementation of Programming Languages Final Exam May 16, pm to 12:45pm (2 hour and 40 minutes) NAME: CS3360 Design and Implementation of Programming Languages Final Exam May 16, 2013 10pm to 12:45pm (2 hour and 40 minutes) NAME: GRADE = / 140 1. Choice of Programming Languages / 25 2. Programming languages:

More information

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I AL GHURAIR UNIVERSITY College of Computing CSC 209 JAVA I week 3- Control Statements: Part I Objectives: To use the if and if...else selection statements to choose among alternative actions. To use the

More information

CSE 1223: Exam II Autumn 2016

CSE 1223: Exam II Autumn 2016 CSE 1223: Exam II Autumn 2016 Name: Instructions: Do not open the exam before you are told to begin. This exam is closed book, closed notes. You may not use any calculators or any other kind of computing

More information

Programming with Java

Programming with Java Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules

More information

St. Edmund Preparatory High School Brooklyn, NY

St. Edmund Preparatory High School Brooklyn, NY AP Computer Science Mr. A. Pinnavaia Summer Assignment St. Edmund Preparatory High School Name: I know it has been about 7 months since you last thought about programming. It s ok. I wouldn t want to think

More information

CS212 Midterm. 1. Read the following code fragments and answer the questions.

CS212 Midterm. 1. Read the following code fragments and answer the questions. CS1 Midterm 1. Read the following code fragments and answer the questions. (a) public void displayabsx(int x) { if (x > 0) { System.out.println(x); return; else { System.out.println(-x); return; System.out.println("Done");

More information

Chapter 4: Control Structures I

Chapter 4: Control Structures I Chapter 4: Control Structures I Java Programming: From Problem Analysis to Program Design, Second Edition Chapter Objectives Learn about control structures. Examine relational and logical operators. Explore

More information

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

CSE 142, Autumn 2010 Midterm Exam, Friday, November 5, 2010 CSE 142, Autumn 2010 Midterm Exam, Friday, November 5, 2010 Name: Section: TA: Student ID #: You have 50 minutes to complete this exam. You may receive a deduction if you keep working after the instructor

More information

Getting started with Java

Getting started with Java Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

More information

Chapter 2 Elementary Programming

Chapter 2 Elementary Programming Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical

More information

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a Spring 2017 Name: TUID: Page Points Score 1 28 2 18 3 12 4 12 5 15 6 15 Total: 100 Instructions The exam is closed book, closed notes. You may not use a calculator, cell phone, etc. i Some API Reminders

More information

Com S 227 Spring 2018 Topics and review problems for Exam 1 Monday, February 19, 6:45 pm Exam locations by last name:

Com S 227 Spring 2018 Topics and review problems for Exam 1 Monday, February 19, 6:45 pm Exam locations by last name: Com S 227 Spring 2018 Topics and review problems for Exam 1 Monday, February 19, 6:45 pm Exam locations by last name: A-B Food Science 2432 C-J LeBaron 1210 *** You must bring your ID to the exam *** K-Q

More information

CS 121 Intro to Programming:Java - Lecture 7 Professor Robert Moll (+ TAs) CS BLDG 276-545-4315 moll@cs.umass.edu course web page below http://twiki-edlab.cs.umass.edu/bin/view/moll121/webhome Announcements

More information

CSCI 1226 Sample Midterm Exam

CSCI 1226 Sample Midterm Exam CSCI 1226 Test #1 February 2017 General Instructions CSCI 1226 Sample Midterm Exam (A bit long since it combines parts of three earlier tests) Read and follow all directions carefully. Name: Student #:

More information

CSIS 10A Assignment 3 Due: 2/21 at midnight

CSIS 10A Assignment 3 Due: 2/21 at midnight CSIS 10A Assignment 3 Due: 2/21 at midnight Read: Chapter 3 Choose and complete any 10 points from the problems below by first downloading the assignment 3 folder from the website. Use BlueJ to complete

More information

Arrays. Weather Problem Array Declaration Accessing Elements Arrays and for Loops Array length field Quick Array Initialization Array Traversals

Arrays. Weather Problem Array Declaration Accessing Elements Arrays and for Loops Array length field Quick Array Initialization Array Traversals Arrays Weather Problem Array Declaration Accessing Elements Arrays and for Loops Array length field Quick Array Initialization Array Traversals Can we solve this problem? Consider the following program

More information

Sample Midterm Exam #2

Sample Midterm Exam #2 Sample Midterm Exam #2 1. Expressions For each expression in the left-hand column, indicate its value in the right-hand column. Be sure to list a constant of appropriate type (e.g., 7.0 rather than 7 for

More information

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

CSE 142, Autumn 2007 Midterm Exam, Friday, November 2, 2007 CSE 142, Autumn 2007 Midterm Exam, Friday, November 2, 2007 Name: Section: Student ID #: TA: Rules: You have 50 minutes to complete this exam. You may receive a deduction if you keep working after the

More information

You will not be tested on JUnit or the Eclipse debugger. The exam does not cover interfaces.

You will not be tested on JUnit or the Eclipse debugger. The exam does not cover interfaces. Com S 227 Fall 2016 Topics and review problems for Exam 2 Thursday, November 10, 6:45 pm Locations, by last name: (same locations as Exam 1) A-C Curtiss 0127, first floor only D-N Hoover 2055 O-Z Troxel

More information

Problem Grade Total

Problem Grade Total CS 101, Prof. Loftin: Final Exam, May 11, 2009 Name: All your work should be done on the pages provided. Scratch paper is available, but you should present everything which is to be graded on the pages

More information

You must bring your ID to the exam.

You must bring your ID to the exam. Com S 227 Spring 2017 Topics and review problems for Exam 2 Monday, April 3, 6:45 pm Locations, by last name: (same locations as Exam 1) A-E Coover 2245 F-M Hoover 2055 N-S Physics 0005 T-Z Hoover 1213

More information

Recitation: Loop Jul 7, 2008

Recitation: Loop Jul 7, 2008 Nested Loop Recitation: Loop Jul 7, 2008 1. What is the output of the following program? Use pen and paper only. The output is: ****** ***** **** *** ** * 2. Test this program in your computer 3. Use "for

More information

CS 101 Fall 2006 Midterm 1 Name: ID:

CS 101 Fall 2006 Midterm 1 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

Chapter 2 ELEMENTARY PROGRAMMING

Chapter 2 ELEMENTARY PROGRAMMING Chapter 2 ELEMENTARY PROGRAMMING Lecture notes for computer programming 1 Faculty of Engineering and Information Technology Prepared by: Iyad Albayouk ١ Objectives To write Java programs to perform simple

More information

Write a program which converts all lowercase letter in a sentence to uppercase.

Write a program which converts all lowercase letter in a sentence to uppercase. Write a program which converts all lowercase letter in a sentence to uppercase. For Example: 1) Consider a sentence "welcome to Java Programming!" its uppercase conversion is " WELCOME TO JAVA PROGRAMMING!"

More information

CSCI 135 Midterm Fundamentals of Computer Science I Fall 2011

CSCI 135 Midterm Fundamentals of Computer Science I Fall 2011 CSCI 135 Midterm Fundamentals of Computer Science I Fall 2011 Name: This exam consists of 12 problems on the following 11 pages. You may use your single- side hand- written 8 ½ x 11 note sheet during the

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

Reviewing all Topics this term

Reviewing all Topics this term Today in CS161 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for) Functions (pass by value, pass by reference) Arrays (specifically arrays of characters)

More information

CS170 Introduction to Computer Science Midterm 2

CS170 Introduction to Computer Science Midterm 2 CS170 Introduction to Computer Science Midterm 2 03/25/2009 Name: Solution You are to honor the Emory Honor Code. This is a closed book and closednotes exam, and you are not to use any other resource than

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3: Parameters, Return, and Interactive Programs with Scanner 1 Lecture outline console input with Scanner objects input tokens Scanner as a parameter to a method cumulative

More information

Midterm Examination (MTA)

Midterm Examination (MTA) M105: Introduction to Programming with Java Midterm Examination (MTA) Spring 2013 / 2014 Question One: [6 marks] Choose the correct answer and write it on the external answer booklet. 1. Compilers and

More information

Department of Computer Science Purdue University, West Lafayette

Department of Computer Science Purdue University, West Lafayette Department of Computer Science Purdue University, West Lafayette Fall 2011: CS 180 Problem Solving and OO Programming Exam 1 Solutions Q 1 Answer the questions below assuming that binary integers are represented

More information

Example: Monte Carlo Simulation 1

Example: Monte Carlo Simulation 1 Example: Monte Carlo Simulation 1 Write a program which conducts a Monte Carlo simulation to estimate π. 1 See https://en.wikipedia.org/wiki/monte_carlo_method. Zheng-Liang Lu Java Programming 133 / 149

More information

Lecture 2. CS118 Term planner. Refinement. Recall our first Java program. Program skeleton GCD. For your first seminar. For your second seminar

Lecture 2. CS118 Term planner. Refinement. Recall our first Java program. Program skeleton GCD. For your first seminar. For your second seminar 2 Lecture 2 CS118 Term planner For your first seminar Meet at CS reception Bring The Guide Bring your CS account details Finish the problem sheet in your own time Talk to each other about the questions

More information

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

Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 45 Obtained Marks: كلية الحاسبات وتقنية المعلوما Exam 1 Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: October 18, 2015 Student Name: Student ID: Total Marks: 45 Obtained Marks: Instructions: Do not open this

More information

Computer Programming, I. Laboratory Manual. Experiment #6. Loops

Computer Programming, I. Laboratory Manual. Experiment #6. Loops Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #6

More information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

1. Which of the following is the correct expression of character 4? a. 4 b. 4 c. '\0004' d. '4' Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java

More information

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

CS 170 Exam 1. Version: B Fall Name (as on OPUS): CS 170 Exam 1 Version: B Fall 2015 Name (as on OPUS): Section: Seat Assignment: Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us or http://www.class-notes.info or http://www.lecture-notes.tripod.com

More information

Introduction to Java Unit 1. Using BlueJ to Write Programs

Introduction to Java Unit 1. Using BlueJ to Write Programs Introduction to Java Unit 1. Using BlueJ to Write Programs 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save

More information

SAMPLE EXAM Second Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 11 November 2010

SAMPLE EXAM Second Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 11 November 2010 SAMPLE EXAM Second Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 11 November 2010 NAME (Printed) NAME (Signed) E-mail Exam Rules Show all your work. Your

More information