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

Similar documents
Lesson 36: for() Loops (W11D1)

Lesson 12: OOP #2, Accessor Methods (W03D4)

AP Computer Science Unit 1. Writing Programs Using BlueJ

Mid Term Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Total Marks: 50 Obtained Marks:

AP Computer Science Unit 1. Writing Programs Using BlueJ

Lesson 24: Recursive Algorithms #1 (W07D3)

Introduction to Java Unit 1. Using BlueJ to Write Programs

Lesson 26: ArrayList (W08D1)

AP Computer Science Summer Assignment (updated 5/29/2018) DUE : Sept. 4, 2018

Lesson 39: Conditionals #3 (W11D4)

Lesson 04: Our First Java Program (W01D4

RANDOM NUMBER GAME PROJECT

Lab 1: Silver Dollar Game 1 CSCI 2101B Fall 2018

Lesson 38: Conditionals #2 (W11D3)

There are several files including the start of a unit test and the method stubs in MindNumber.java. Here is a preview of what you will do:

St. Edmund Preparatory High School Brooklyn, NY

Managing Your Grade Book This lesson will show you how to set up your grade book columns and have Canvas calculate your final grades for you.

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

Tips from the experts: How to waste a lot of time on this assignment

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

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling

Remote Access Instructions. remote.gpmlaw.com

CMPSCI 187 / Spring 2015 Postfix Expression Evaluator

AP Computer Science Java Mr. Clausen Program 6A, 6B

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

Lesson 2.4 Arraylist

4. Java Project Design, Input Methods

AP Computer Science Unit 1. Programs

4. Java language basics: Function. Minhaeng Lee

AP Computer Science A Summer Assignment 2017

7. Arrays, More Java Looping

Chapter 1 Lab Algorithms, Errors, and Testing

My Lakeland Student Guide

C Sc 227 Project 1: Three Main Methods

Array. Array Declaration:

Object Oriented Programming with JAVA

Summer Assignment for AP Computer Science. Room 302

Question 1 [20 points]

AP Computer Science Lists The Array type

COMP110 Jump Around. Go ahead and get today s code in Eclipse as shown on next few slides. Kris Jordan

Introduction to Computer Programming

Sample Spark Web-App. Overview. Prerequisites

CSE 1223: Introduction to Computer Programming in Java Chapter 6 ArrayLists

2.8. Decision Making: Equality and Relational Operators

School of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15

User Manual. perfectionlearning.com/technical-support

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

Darrell Bethea May 25, 2011

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

Question: Total Points: Score:

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 8 Assigned: October 26, 2016 Due: November 2, 2016 by 2:30pm

Lesson 7 Part 2 Flags

Java Identifiers, Data Types & Variables

Decisions: Logic Java Programming 2 Lesson 7

Claremont McKenna College Computer Science

Announcements. 1. Forms to return today after class:

Lecture 8 " INPUT " Instructor: Craig Duckett

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

AP Computer Science Summer Work Mrs. Kaelin

Check out how to use the random number generator (introduced in section 4.11 of the text) to get a number between 1 and 6 to create the simulation.

Anatomy of a Java Program: Comments

Lecture 10. Instructor: Craig Duckett

1.00/1.001 Tutorial 1


(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Arrays. Eng. Mohammed Abdualal

Section 2.2 Your First Program in Java: Printing a Line of Text

IT115: Introduction to Java Programming 1. IT115: Introduction to Java Programming. Tic Tac Toe Application. Trina VanderLouw

1. The programming language C is more than 30 years old. True or False? (Circle your choice.)

Object Oriented Programming. Java-Lecture 6 - Arrays

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

CSE 332: Data Structures and Parallelism Winter 2019 Setting Up Your CSE 332 Environment

Fundamentals of Programming Data Types & Methods

Social Media Managers Course - Navigation Guide

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

ECE 161 WEEK 4 Introduction to Programing in Java

Lecture 02, Fall 2018 Friday September 7

JAVA PROGRAMMING (340)

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CMPSCI 187 / Spring 2015 Hanoi

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

For those working on setting up Super Star Online for the school year, here are a few tips:

Eng. Mohammed Alokshiya

CMSC 150 INTRODUCTION TO COMPUTING LAB WEEK 3 STANDARD IO FORMATTING OUTPUT SCANNER REDIRECTING

CMPSCI 187 / Spring 2015 Hangman

(First is used here)

CMPSC 111 Introduction to Computer Science I Fall 2016 Lab 2 Assigned: September 7, 2016 Due: Wednesday, September 14, 2016 by 2:30 pm

CSC207 Week 4. Larry Zhang

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

Kaltura Blackboard Building Block - KAF

Chapter 6 Lab Classes and Objects

Question: Total Points: Score:

Using the elab LMS Integration Tool in a Canvas Course

10/1/2018 Programming Data Structures. Quiz Exception Handling

Section 2.2 Your First Program in Java: Printing a Line of Text

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Oct Decision Structures cont d

Chapter 6 Lab Classes and Objects

CS201 - Assignment 3, Part 2 Due: Wednesday March 5, at the beginning of class

Transcription:

Lesson 10: Quiz #1 and Getting User Input (W03D2) Balboa High School Michael Ferraro September 1, 2015 1 / 13

Do Now: Prep GitHub Repo for PS #1 You ll need to submit the 5.2 solution on the paper form and to GitHub. In Eclipse, create a project called ps01 (lowercase!). Add a file to the src folder called Ch2Num11.java. Add a class declaration and main() to the file. Use github-push.sh to push this project to GitHub: cd ~/MOUNTED/apcs-locker/workspace0/ps01 github-push.sh GITHUB_USERNAME PERIOD When you work from home, change the file using your web browser. 2 / 13

Aim Students will take Quiz #1 and learn how to write a Java program to prompt the user for input values via a Scanner. 3 / 13

After the Quiz Once you ve finished the quiz: bring your quiz to me remain quiet as a courtesy to those still working open up this set of lesson slides move through the remaining slides on your own HW is on the last slide! 4 / 13

Prompting the User for Data Let s play with an interactive app! We will ask the user for two integers and then display the product. 5 / 13

Prompting the User for Data 1 Within workspace0, create a new Eclipse project called InteractiveInts 2 Download InteractiveInts.java from here, saving the file to your Desktop 3 Drag-and-drop the file from the Desktop to the src folder inside your new Eclipse project. This is how you import downloaded files into Eclipse projects just like you ll need to do when downloading Java source files from the problem sets or after saving email attachments. 4 Run the program. 6 / 13

Inside InteractiveInts import java.util.scanner; public class InteractiveInts {... //3 dots here just means some code has been omitted f import statements at the top of a Java class tell the compile where some tool is located. In this case, we re using a Java-provided tool called a Scanner, which is useful for capturing what a user types (among other things that we ll go into later). 7 / 13

Inside InteractiveInts import java.util.scanner; public class InteractiveInts { public static void main(string[] args) { Scanner keybd = new Scanner(System.in);... int firstint = new Integer(keybd.nextLine());... keybd is the name of a Scanner object we have created. 8 / 13

Inside InteractiveInts import java.util.scanner; public class InteractiveInts { public static void main(string[] args) { Scanner keybd = new Scanner(System.in);... int firstint = new Integer(keybd.nextLine());... Where you see keybd.nextline(), we re asking the Scanner called keybd to read in the characters that the user types until [ENTER] is pressed. 9 / 13

Inside InteractiveInts import java.util.scanner; public class InteractiveInts { public static void main(string[] args) { Scanner keybd = new Scanner(System.in);... int firstint = new Integer(keybd.nextLine());... That typed value is turned into an integer, if possible, and then stored in the int variable called firstint. 10 / 13

Things to Try What happens if you type abc and press [ENTER] when asked to provide an integer? How does the program behave if you provide a non-integer value at one or both prompts? For example, try entering 2.1 during one program run and 2.9 the next time. 11 / 13

PS #1 Tip: Tic-Tac-Toe Problem Ch. 1, #16: Your job is to represent a game of tic-tac-toe using a string of 0s and 1s. decide how to represent X, O, and blanks 1 using bits include an example board and how you d represent the game state using bits don t use more bits than you need make sure you explain your system for representing the game state in a way that your teacher will easily understand that will affect your grade! 1 Students commonly forget to represent blanks on the board. Imagine you re saving a game that s halfway played to continue playing later; blank locations need to be remembered. 12 / 13

HW PS #1, 5.1 make sure you have your Java source file available at school so you can get a sign-off be prepared to explain how your program works Finish the remaining sections of PS #1 web questions due at the start of 5 th Period! Paper form should be turned in during next class, but will be accepted for full credit by 4:00PM on Friday. Don t procrastinate on sign-offs: Your teacher won t accept a flood of sign-offs on the last day. Having trouble? Post questions on the course website under the PS #1 post. 13 / 13