Activity 1: Introduction

Similar documents
Activity 1: Introduction

Activity 6: Loops. Content Learning Objectives. Process Skill Goals

Activity 6: Loops. Content Learning Objectives. Process Skill Goals

Activity 3: Data Types

Activity 4: Boolean Logic

Activity 7: Arrays. Content Learning Objectives. Process Skill Goals

Activity 9: Object-Oriented

Activity 11: Designing Classes

Lab 9: Creating a Reusable Class

Activity 9: Object-Oriented

Properties and Definitions

Datatypes, Variables, and Operations

Activity 4: Methods. Content Learning Objectives. Process Skill Goals

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

Fundamentals of Programming CS-110. Lecture 2

Introduction to Java Applications

CEN 414 Java Programming

Watkins Mill High School. Algebra 2. Math Challenge

5.OA Why Do We Need an Order of Operations?

EXCEL BASICS: MICROSOFT OFFICE 2007

This is a combination of a programming assignment and ungraded exercises

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

9/10/10. Arithmetic Operators. Today. Assigning floats to ints. Arithmetic Operators & Expressions. What do you think is the output?

Outline. Program development cycle. Algorithms development and representation. Examples.

CIS133J. Working with Numbers in Java

Introduction to Java Unit 1. Using BlueJ to Write Programs

CSCE 120: Learning To Code

JAVA OPERATORS GENERAL

and numbers and no spaces. Press after typing the name. You are now in the Program Editor. Each line of code begins with the colon character ( : ).

VBScript: Math Functions

Advanced Algebra I Simplifying Expressions

last time in cs recitations. computer commands. today s topics.

Introduction to Programming in Turing. Input, Output, and Variables

EXCEL BASICS: MICROSOFT OFFICE 2010

AP Computer Science Unit 1. Writing Programs Using BlueJ

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92

CISC 181 Lab 2 (100 pts) Due: March 7 at midnight (This is a two-week lab)

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Full file at

Computer Science 1 Honors

Full file at

Introduction to Computer Science Unit 2. Notes

AP Computer Science Unit 1. Writing Programs Using BlueJ

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

Java Simple Data Types

CSI33 Data Structures

Chapter 8 Patterns. Examples: a, b, c,, x, y, z

Algebra 1. Standard 11 Operations of Expressions. Categories Combining Expressions Multiply Expressions Multiple Operations Function Knowledge

Values, Variables, Types & Arithmetic Expressions. Agenda

Primitive Data, Variables, and Expressions; Simple Conditional Execution

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

I. Variables and Data Type week 3

Java Simple Data Types

Object-Oriented Programming

Arrays. Theoretical Part. Contents. Keywords. Programming with Java module 3

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG

Anatomy of a Java Program: Comments

Introduction to Programming COIT 20245

Mathematical Reasoning. Lesson 47: Prisms and Cylinders. LESSON 47: Prisms and Cylinders. D. Legault, Minnesota Literacy Council,

Introduction to Excel 2007

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: Text-printing program. CSC 209 JAVA I

4. Assignment statements Give an assignment statement that sets the value of a variable called total to 20: Answer: total = 20;

ROCHESTER COMMUNITY SCHOOL MATHEMATICS SCOPE AND SEQUENCE, K-5 STRAND: NUMERATION

Chapter 1: Foundations for Algebra

CSCE 145 Exam 1 Review Answers. This exam totals to 100 points. Follow the instructions. Good luck!

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

Chapter Two Bonus Lesson: JavaDoc

Grouping Objects. Primitive Arrays and Iteration. Produced by: Dr. Siobhán Drohan. Department of Computing and Mathematics

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2014/2015 CI101/CI101H. Programming

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

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

Excel 2016: Part 1. Updated January 2017 Copy cost: $1.50

Introduction to Programming EC-105. Lecture 2

CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck!

1. Look carefully at the program shown below and answer the questions that follow.

Lab 1: Input, Processing, and Output This lab accompanies Chapter 2 of Starting Out with Programming Logic & Design.

Programming with Java

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

Topic 2: Decimals. Topic 1 Integers. Topic 2 Decimals. Topic 3 Fractions. Topic 4 Ratios. Topic 5 Percentages. Topic 6 Algebra

Sand Springs Public Schools 3rd Grade Math Common Core State Standards

Lesson 5: Introduction to the Java Basics: Java Arithmetic THEORY. Arithmetic Operators

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

Overview. Lab 5 Methods and Parameters

Course Outlines. Elementary Mathematics (Grades K-5) Kids and Numbers (Recommended for K-1 students)

Chapter 1 - What s in a program?

Integers and Rational Numbers

Skill 1: Multiplying Polynomials

Introduction to Computer Science Unit 2. Notes

PROGRAMMING FUNDAMENTALS

Year 6 Term 1 and

Test Conversion Service

Algorithms and Programming I. Lecture#12 Spring 2015

Work Smart: Make presence work for you

More About Objects and Methods. Objectives. Outline. Chapter 6

More About Objects and Methods

LOOPS. 1- Write a program that prompts user to enter an integer N and determines and prints the sum of cubes from 5 to N (i.e. sum of 5 3 to N 3 ).

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

ML 1 Basic OCaml. 1 Change Log. 2 Objectives and Background. 3 Done in Computer-Based Testing Facility. 4 Problems

Microsoft Excel Level 2

(First is used here)

Transcription:

Activity 1: Introduction In this course, you will work in teams of 3 4 students to learn new concepts. This activity will introduce you to the process. We ll also take a first look at how to store data in Java programs. Content Learning Objectives After completing this activity, students should be able to: Describe the responsibility of each team role. Identify components of the "hello world" program. Write Java code to declare int and double variables. Explain what it means to assign a value to a variable. Process Skill Goals During the activity, students should make progress toward: Leveraging prior knowledge and experience of other students. (Teamwork) Copyright 2017 Chris Mayfield and Helen Hu. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Model 1 Team Roles Decide who will be what role for today; we will rotate the roles each week. If you have only three people, one should have two roles. If you have five people, two may share the same role. Manager: Presenter: Recorder: Reflector: Questions (15 min) 1. What is the difference between bold and italics on the role cards? 2. Manager: invite each person to explain their role to the team. Recorder: take notes of the discussion by writing down key phrases next to the table above. 3. What responsibilities do two or more roles have in common? 4. For each role, give an example of how someone observing your group would know that a person is not doing their job well. Manager: Presenter: Recorder: Reflector:

Model 2 Hello, World! Questions (10 min) 5. What is the name of the class? What is the name of the file? What directory is it in? 6. How many lines of code is the above program? How many statements does it have? 7. What is the purpose of the first six lines? What is the purpose of the two blank lines? 8. Describe in your own words what System.out.println does. Be very specific.

Model 3 Variables Most programs store and manipulate data values, and we use variables to give them meaningful names. The following code declares and assigns three variables. Each variable is stored in the computer s memory, represented by the boxes on the right. Java code int dollars; int cents; double grams; dollars = 1; cents = 90; grams = 3.5; Computer memory dollars 1 cents 90 grams 3.5 Questions (10 min) 9. Identify the Java keyword used in a variable declaration to indicate a) an integer: b) a real number: 10. Consider numbers of dollar bills, cents, and grams. Which of these units only makes sense as an integer, and why? 11. What would you expect the following statements to print out? a) System.out.println(dollars); b) System.out.println(cents); c) System.out.println(grams); 12. In the previous question, how does the third printed line (c) differ from the first two?

13. What do you think is the purpose of a variable declaration? 14. What is output by the following code, and why? double one; one = 1; System.out.println(one); Model 4 Assignment Declaring a variable instructs the computer to reserve space for it in memory. Java code 1 int dollars; 2 int cents; Computer memory dollars cents Variables cannot be used until they are initialized (assigned for the first time). 3 dollars = 2; 4 System.out.println(dollars); // OK 5 System.out.println(cents); // error dollars 2 cents Each time you assign a variable, you are updating its value stored in memory. 6 dollars = 3; 7 dollars = 4; 8 cents = 49; dollars 4 cents 49 Questions (10 min) 15. How many times is each variable in Model 4 assigned?

16. What is the error in the second System.out.println statement? (Don t just repeat the text in Model 4; explain in your own words what the problem is.) 17. What is the value of dollars right before it s assigned for the last time? What is the value of cents before it s assigned for the last time? 18. Consider the statement: cents = dollars; a) Compare this code to lines 6 8 in Model 4. What value do you think cents and dollars will have after running this statement? b) Which side of the equals sign (left or right) was assigned a new value? 19. In Java, the + and - symbols are used to perform addition and subtraction. For example, the statement dollars = dollars + 1; adds one to the current value of dollars. a) What is the value of dollars (in memory) after running this statement? b) Do you consider the equals sign in Java an operation to be performed? (like +) If so, explain the operation. If not, explain why not. c) Do you consider the equals sign in mathematics an operation to be performed? If so, explain the operation. If not, explain why not. 20. In your own words, explain how you should read the = sign in Java. For example, the Java statement x = a + b; should be read as x a plus b.

Model 5 A Very Simple Algorithm Questions (10 min) A Circle Formula for Area Algorithm for Area 2.0 Area = pr 2 - the variable radius gets the value 2.0 - square the radius - multiply the radius by the constant p - store the result in area 21. What does 2.0 represent in the circle diagram? 22. What line in the algorithm corresponds to assigning the radius the value of 2? Write the whole line below. 23. Translate the algorithm into as close to java code as possible from what you now know. 24. On the back of the page, write an algorithm in English for prompting a user for three numbers, computing the sum and displaying the result.