A+ Computer Science -

Similar documents
A+ Computer Science -

A+ Computer Science -

Reading Input from Text File

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

ing execution. That way, new results can be computed each time the Class The Scanner

Experiment No: Group B_4

Fundamentals of Programming Data Types & Methods

Robots. Byron Weber Becker. chapter 6

Variables and Assignments CSC 121 Spring 2017 Howard Rosenthal

Computational Expression

Objects and Classes 1: Encapsulation, Strings and Things CSC 121 Fall 2014 Howard Rosenthal

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4

BASIC INPUT/OUTPUT. Fundamentals of Computer Science

Lecture 6. Assignments. Summary - Variables. Summary Program Parts 1/29/18. Reading: 3.1, 3.2, 3.3, 3.4

A token is a sequence of characters not including any whitespace.

Basic Computation. Chapter 2

Lecture 8 " INPUT " Instructor: Craig Duckett

Chapter 4: Conditionals and Recursion

String s = "apluscs";

Data Conversion & Scanner Class

CSS 161 Fundamentals of Compu3ng. Assignments, Expressions, Operators, Console input & output October 1, 2012

Lecture Set 2: Starting Java

Lecture Set 2: Starting Java

Computational Expression

Basic Computation. Chapter 2

Using Classes. GEEN163 Introduction to Computer Programming

COMP String and Console I/O. Yi Hong May 18, 2015

Console Input and Output

Computational Expression

Chapter 5 Lab Methods

1 Short Answer (5 Points Each)

Using APIs. Chapter 3. Outline Fields Overall Layout. Java By Abstraction Chapter 3. Field Summary static double PI

We now start exploring some key elements of the Java programming language and ways of performing I/O

Chapter 2 ELEMENTARY PROGRAMMING

Basic Computation. Chapter 2

Programming with Java

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

Object Oriented Programming. Java-Lecture 1

1 Short Answer (10 Points Each)

Programming II (CS300)

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string

Over and Over Again GEEN163

Chapter 4: Loops and Files

Full file at

Lesson 02 Data Types and Statements. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Chapter 5 Lab Methods

Lecture Notes. System.out.println( Circle radius: + radius + area: + area); radius radius area area value

Project 1. Java Data types and input/output 1/17/2014. Primitive data types (2) Primitive data types in Java

Full file at

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

Chapter 4: Loops and Files

! 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

ECE 122 Engineering Problem Solving with Java

Topic 11 Scanner object, conditional execution

Chapter 5 Lab Methods

Classes and Objects Part 1

AP Computer Science Unit 1. Programs

Chapter 2. Elementary Programming

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

Using Classes and Objects Chapters 3 Creating Objects Section 3.1 The String Class Section 3.2 The Scanner Class Section 2.6

Introduction to Java Unit 1. Using BlueJ to Write Programs

Chapter 1 Lab Algorithms, Errors, and Testing

H212 Introduction to Software Systems Honors

Using Java Classes Fall 2018 Margaret Reid-Miller

MIDTERM REVIEW. midterminformation.htm

Lesson 7 Part 2 Flags

Example Program. public class ComputeArea {

CMSC131. Introduction to your Introduction to Java. Why Java?

CS 106 Introduction to Computer Science I

Chapter 2 Elementary Programming

Objectives. Primitive Types, Strings, and Console I/O. Variables and Values. Outline. Naming and Declaring Variables. Variables and Values

4. Java language basics: Function. Minhaeng Lee

COMP 110/L Lecture 4. Kyle Dewey

1 Short Answer (5 Points Each)

Computer Science 210 Data Structures Siena College Fall Topic Notes: Methods

Loops. GEEN163 Introduction to Computer Programming

2. What are the two main components to the CPU and what do each of them do? 3. What is the difference between a compiler and an interpreter?

A variable is a name for a location in memory A variable must be declared

Important Java terminology

Formatted Output / User IO

1 Definitions & Short Answer (4 Points Each)

A+ Computer Science -

Lesson 02 Data Types and Statements. MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Defining Classes and Methods

CS 302: Introduction to Programming

Topic 11 Scanner object, conditional execution

1 Short Answer (2 Points Each)

Anatomy of a Java Program: Comments

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

AP Computer Science Unit 1. Writing Programs Using BlueJ

ACS-1903 Basic program structure Feb 16, 2017

Computer Science 145 Midterm 1 Fall 2016

Primitive Data Types: Intro

Objects Classes Strings Review CSC 123 Fall 2018 Howard Rosenthal

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

Chapter 2 Primitive Data Types and Operations

5. What is a block statement? A block statement is a segment of code between {}.

Intro to Programming in Java Practice Midterm

STUDENT LESSON A7 Simple I/O

Object-Oriented Programming in Java

Transcription:

Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/apluscomputerscience

import java.util.scanner; Try to be as specific as possible when using an import.

reference variable Scanner keyboard = new Scanner(System.in); object instantiation

Scanner frequently used methods Name nextint() nextdouble() nextfloat() nextlong() nextbyte() nextshort() next() nextline() Use returns the next int value returns the next double value returns the next float value returns the next long value returns the next byte value returns the next short value returns the next one word String returns the next multi word String import java.util.scanner;

Scanner keyboard = new Scanner(System.in); out.print("enter an integer :: "); int num = keyboard.nextint();

out.print("enter an integer :: "); int num = keyboard.nextint(); out.println(num); INPUT 931 OUTPUT Enter an integer :: 931 931

reference variable int num = keyboard.nextint(); method call

out.print("enter an integer :: "); Prompts are used to tell the user what you want.

Scanner keyboard = new Scanner(System.in); out.print("enter a double :: "); double num = keyboard.nextdouble();

out.print("enter a double :: "); double num = keyboard.nextdouble(); out.println(num); INPUT 34.33 OUTPUT Enter a double :: 34.33 34.33

reference variable double num = keyboard.nextdouble(); method call

Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/apluscomputerscience

Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/apluscomputerscience

Scanner keyboard = new Scanner(System.in); out.print("enter a string :: "); String word = keyboard.next();

out.print("enter a string :: "); String word = keyboard.next(); out.println(word); INPUT I love java. OUTPUT Enter a string :: I love java. I

Scanner keyboard = new Scanner(System.in); out.print("enter a sentence :: "); String sentence = keyboard.nextline();

out.print("enter a line :: "); String line = keyboard.nextline(); out.println(line); INPUT I love java. OUTPUT Enter a line :: I love java. I love java.

out.print("enter an integer :: "); int num = keyboard.nextint(); out.print("enter a sentence :: "); String sentence = keyboard.nextline(); out.println(num + " "+sentence); OUTPUT Enter an integer :: 34 Enter a sentence :: 34 INPUT 34 picks up \n nextline() picks up whitespace.

out.print("enter an integer :: "); int num = keyboard.nextint(); keyboard.nextline(); out.print("enter a sentence :: "); String sentence = keyboard.nextline(); out.println(num + " "+sentence); OUTPUT Enter an integer :: 34 Enter a sentence :: picks up \n 34 picks up \n //pick up whitespace INPUT 34 picks up \n nextline() picks up whitespace.

Scanner keyboard = new Scanner(System.in); INPUT 1 2 3 4 5 out.println(keyboard.nextint()); out.println(keyboard.nextint()); out.println(keyboard.nextint()); OUTPUT 1 2 3

Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/apluscomputerscience