St. Edmund Preparatory High School Brooklyn, NY

Similar documents
Darrell Bethea May 10, MTWRF 9:45-11:15 AM Sitterson 011

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

Over and Over Again GEEN163

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

Computer Science AP 2017 Summer Assignment Mrs. McFarland

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Darrell Bethea May 25, 2011

AP Computer Science Unit 1. Writing Programs Using BlueJ

Loops. Eng. Mohammed Abdualal. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

AP Computer Science Unit 1. Programs

CSCI 1103: Introduction

! definite loop: A loop that executes a known number of times. " The for loops we have seen so far are definite loops. ! We often use language like

Software and Programming 1

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

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

AP Computer Science Unit 1. Writing Programs Using BlueJ

Repetition, Looping. While Loop

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

Full file at

Repe$$on CSC 121 Fall 2015 Howard Rosenthal

BlueJ Demo. Topic 1: Basic Java. 1. Sequencing. Features of Structured Programming Languages

AP Computer Science A

Introduction to Computers and Java

Input. Scanner keyboard = new Scanner(System.in); String name;

Summer Assignment for the School Year

Loops. CSE 114, Computer Science 1 Stony Brook University

AP Computer Science A Unit 2. Exercises

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Java Applications

Repe$$on CSC 121 Spring 2017 Howard Rosenthal

Computer Programming I - Unit 5 Lecture page 1 of 14

Loops and Expression Types

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

Introduction to Java Unit 1. Using BlueJ to Write Programs

COMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements

COMP 202 Java in one week

Software and Programming 1

Methods CSC 121 Fall 2016 Howard Rosenthal

Variables and Assignments CSC 121 Spring 2017 Howard Rosenthal

Question: Total Points: Score:

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

Midterm Examination (MTA)

Mr. Monroe s Guide to Mastering Java Syntax

COMP1406 Tutorial 1. Objectives: Getting Started:

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

COMP 202. Java in one week

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

4. Java Project Design, Input Methods

Please answer the following questions. Do not re-code the enclosed codes if you have already completed them.

COSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan

Summer Assignment for AP Computer Science. Room 302

Java Coding 3. Over & over again!

AP Computer Science A Summer Assignment

Fundamentals of Programming Data Types & Methods

Example Program. public class ComputeArea {

Array Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7)

PRIMITIVE VARIABLES. CS302 Introduction to Programming University of Wisconsin Madison Lecture 3. By Matthew Bernstein

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

Control Statements: Part 1

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

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

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

CSE 1223: Introduction to Computer Programming in Java Chapter 1 Computer Basics

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

1. What is the difference between a compiler and an interpreter? Also, discuss Java s method.

CEN 414 Java Programming

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming

Elementary Programming

Programming with Java

Methods CSC 121 Spring 2017 Howard Rosenthal

Data Types. 1 You cannot change the type of the variable after declaration. Zheng-Liang Lu Java Programming 52 / 87

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

APCS Semester #1 Final Exam Practice Problems

COMP 110 Project 1 Programming Project Warm-Up Exercise

Linked Lists. private int num; // payload for the node private Node next; // pointer to the next node in the list }

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

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

COMP-202 Unit 4: Programming with Iterations

Controls Structure for Repetition

The for Loop, Accumulator Variables, Seninel Values, and The Random Class. CS0007: Introduction to Computer Programming

Motivating Examples (1.1) Selections. Motivating Examples (1.2) Learning Outcomes. EECS1022: Programming for Mobile Computing Winter 2018

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015

Building Java Programs

Software and Programming 1

STUDENT LESSON A7 Simple I/O

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

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

Selections. EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG

Course Outline. Introduction to java

Lecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18

Lesson 10: Quiz #1 and Getting User Input (W03D2)

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Logic is the anatomy of thought. John Locke ( ) This sentence is false.

STUDENT LESSON A12 Iterations

Transcription:

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 about code at the beach either. Since it has been a little while, let s see what you remember from Advanced Computer Science. To the best of your ability, describe the concepts listed below. 1. Algorithm 2. Low Level Languages vs. High Level Languages 3. Complier 4. Variables 5. Variable Type 6. Variable Declarations 7. Output 8. Arithmetic Operators

9. Relational Operators St. Edmund Preparatory High School 10. Conditional Statements (C++: IF and IF Else) 11. AND statements 12. OR statements 13. Loop 14. Functions 15. Classes 16. Objects Page 2 of 8

St. Edmund Preparatory High School Many of the basic programming concepts exist in every programming language. There are many things you already know what they do and/or how they work. This year you are going to learn some different ways to write those basic programming concepts. Below is a sample Java program from your textbook (pg. 15). While you may not understand all of the code in this program and what the specific instructions are, it is very likely you can tell me what the parts of this program are doing. Label the parts of this program and, based on your knowledge, describe what the line(s) of code does. 1 Import java.util.scanner; 2 3 Public class FirstProgram 4 { 5 public static void main(string[] args) 6 { 7 System.out.println( Hello out there. ); 8 System.out.println( I will add two numbers for you. ); 9 System.out.println( Enter two whole numbers on a line: ); 10 11 int n1, n2; 12 13 Scanner keyboard = new Scanner(System.in); 14 n1 = keyboard.nextint(); 15 n2 = keyboard.nextint(); 16 System.out.println( The sum of those two numbers is ); 17 System.out.println(n1 + n2); 18 } 19 } Page 3 of 8

Using BlueJ St. Edmund Preparatory High School For Java, we will be using a new compiler called BlueJ. It is very similar to the Visual Studio Compiler that you used for C++. Here I would like to walk you through the process of coding, compiling, and running a program in BlueJ. 1) Lucky for us, BlueJ is a free, open-source program! It is available for both Windows and Mac OS. Begin by downloading and running the installer files from www.bluej.org 2) Run the program. Being by selecting Project New Project. This will ask you to create a folder for your project. I highly suggest using your flash drive to save your work. This way you will have your files both at home and at school. Name this first folder firstprogram. 3) On the next screen, Select New Class from the left-hand menu. For most of our class we will be creating files of the Class Type Class. (We will talk about Abstracts and Interfaces much later on in the course.) Call this first class FirstProgram. Click Ok Note: Typical naming convention calls for the name of classes to be one word and begin with an uppercase letter. If you have a name of a class that is made up of multiple words, capitalize the first letter of each new word. Class names cannot begin with a number or symbol. Valid Class Names FirstProgram StringManipulation4 FinalExamAverages Invalid Class Names first program String Manipulation 4 2015FinalExamAvg Page 4 of 8

St. Edmund Preparatory High School 4) You should now see a yellow box with the class name in the BlueJ window. You can double click the class to begin programming. BlueJ will always give you a basic shell template of code to work with. 5) For our purposes, we are going to compile and run the sample program from page 3. Replace the entire Java template provided by BlueJ with the code below. You can copy and paste the following: Page 5 of 8

//AP Computer Science //First Java Sample Program import java.util.scanner; St. Edmund Preparatory High School public class FirstProgram { public static void main(string[] args) { System.out.println("Hello out there."); System.out.println("I will add two numbers for you."); System.out.println("Enter two whole numbers on a line:"); int n1, n2 Scanner keyboard = new Scanner(System.in); n1 = keyboard.nextint(); n2 = keyboard.nextint(); System.out.println("The sum of these two numbers is"); System.out.println(n1 + n2); } } 6) To make coding a bit easier to follow, BlueJ can mark your code with line numbers and highlighting. To set these preferences, select the Options Menu Preferences. On the next window make sure Use syntax highlighting and Display line numbers are checked off. Click OK. 7) When you are done coding, save your class and click Compile. The compiler will now compile your code and do basic error checking. If there are errors, you will see them appear in the window at the bottom of screen. In this example I have intentionally left out a semicolon at the end of line 14. When you compile, you will see the line become highlighted, and the error message in the bottom window. If you add the semicolon (;) to the end of line 14 and recompile, you will see the error go away. The window should now say Class compiled no syntax errors. Close the class. Page 6 of 8

St. Edmund Preparatory High School 8) To run the compiled program, right click the class you just compiled and select the name of the main program you wrote. In this case select void main (String[] args). Then click ok on the next window. 9) The terminal window will open, and you will see the output of the program. 10) Congratulations! You have written your first Java program! Page 7 of 8

St. Edmund Preparatory High School Join our Google Classroom: Join Code ka31gr Review of Programming Topics from C++ Much of the basic programming concepts that you learned in C++ are similar, if not identical, to Java. Let s see what you remember and show you how concepts can be a bit different in Java. For this summer, I will ask you to work through some lessons in a text book Blue Pelican Java, by Charles Cook. We will use this text book throughout the year in addition to another text, Java: An Introduction to Problem Solving, by Walter Savitch. You will pick up the Savitch text in September. I have the BPJ text in PDF format, which you can download from the following link: tinyurl.com/bpjtextbook Please read the following lessons and complete the questions and programs listed. Exercises responses should be typed. Projects should be written, compiled, and run using BlueJ. As you are reading and doing these exercises, you may run into concepts, syntax, and/or vocabulary that you do not understand or are particularly challenging. Please keep a running list of questions. We can address these questions in September Lesson Page Questions/Programs 1 Hello World Pg. 1-3 Project - From Me To You 2 Variable Types Pg. 2-3 Exercise on Lesson 2 #1-12 3 Simple String Operations Pg. 3-3 Exercise on Lesson 3 #1-12 Project Name that Celebrity 4 Using Numeric Variables Pg. 4-3 Exercise on Lesson 4 #1-18 Project - Cheating on Your Arithmetic Assignment 5 Mixed Data Types, Casting, and Constants Pg. 5-2 Project Mixed Results 7 Input from the Keyboard Pg. 7-3 Project What s My Name? 8 The Boolean Type and Boolean Operators Pg. 8-3 Exercise on Lesson 8 #1-18 9 The if Statement Pg. 9-3 Exercise on Lesson 9 #1-20 Project Even or Odd? 11 The for-loop Pg. 11-4 Exercise on Lesson 11 #1-14 12 The while & do-while loops Pg. 12-3 Exercise on Lesson 12 #1-14 Programs 7 & 8 below Program 7 Write a fragment of code that will compute the sum of the first n positive odd integers. Prompt the user to enter n for the number of digits they would like to compute. For example, if n is 5, you should compute 1 + 3 + 5 + 7 + 9. Program 8 Write a program to read a list of nonnegative integers and to display the largest integer, the smallest integer, and the average of all the integers. The user indicates the end of the input by entering a negative sentinel value that is not used in finding the largest, smallest, and average values. The average should be a value of type double, so that it is computed with a fractional part. Let me know if you have any questions. Feel free to email me at apinnavaia@stedmundprep.org if there is something that is really giving you a problem. Have a great summer and happy coding! Page 8 of 8