Chapter 2 Practice.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
We Have Learned main() { … } Variable –Definition –Calculation –Display We can do some real programming! –Think about your solution design –Express design.
Variables – the Key to Programming. ICS-3M1 - Mr. Martens - Variables Part 1 What is a Variable? A storage location that is given a “name” You can store.
Java Planning our Programs Flowcharts Arithmetic Operators.
Chapter 2 Review Questions
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
CS 1400 Chapter 2 sections 1, 2, 4 – 6, 8,
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: Numeric Data *Variables *Numeric data.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
11 Chapter 5 METHODS. 22 INTRODUCTION TO METHODS A method is a named block of statements that performs a specific task. Other languages use the terms.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Java for Beginners University Greenwich Computing At School DASCO
1 CS 192 Lecture 5 Winter 2003 December 10-11, 2003 Dr. Shafay Shamail.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
How to Work with Numeric and String Data
Java Data Types. Primitive Data Types Java has 8 primitive data types: – char: used to store a single character eg. G – boolean: used to store true or.
BUILDING JAVA PROGRAMS CHAPTER 7 Arrays. Exam #2: Chapters 1-6 Thursday Dec. 4th.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Defining and Converting Data Copyright Kip Irvine, 2003 Last Update: 11/4/2003.
Today’s topic:  Arithmetic expressions. Arithmetic expressions  binary (two arguments) arithmetic operators  +, -, *, /, % (mod or modulus)  unary.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Static Methods. 2 Objectives Look at how to build static (class) methods Study use of methods calling, parameters, returning values Contrast reference.
Variables and Math in Code. Variables A variable is a storage block for information in your program “A” “A” Computer Program Memory Computer Program.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
02 Variables1November Variables CE : Fundamental Programming Techniques.
BUILDING JAVA PROGRAMS CHAPTER 2 VARIABLES AND STRING CONCATENATION.
Variables in Java x = 3;. What is a variable?  A variable is a placeholder in memory used by programmers to store information for a certain amount of.
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Chapter 2 Variables.
Using Recursion to Convert Number to Other Number Bases Data Structures in Java with JUnit ©Rick Mercer.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Additional Pair Programming Exercises 1. Problem 1 For a wheel of radius r feet, how many revolutions are required for that wheel to travel 1 mile? What.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
CS Jan 2007 Chapter 2 sections 1, 2, 4 – 6, 8,
1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
PHP Variables.  Variables are "containers" for storing information. How to Declare PHP Variables  In PHP, a variable starts with the $ sign, followed.
Chapter 3 Numerical Data. Objectives After you have read and studied this chapter, you should be able to Select proper types for numerical data. Write.
More than just a song and dance.. They are objects that store primitive variable values: Integer – stores an int Double – stores a double Character –
I’m Thinking of a Number
Expressions and Order of Operations Operators – There are the standard operators: add, subtract, divide, multiply – Note that * means multiply? (No times.
COP 2551 Introduction to Object Oriented Programming with Java Topics –Introduction to the Java language –Code Commenting –Java Program Structure –Identifiers.
JAVA CLASSES, METHODS AND VARIABLES.  Defined Noun: A set or category of things having some property or attribute in common and differentiated from others.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Inside Class Methods Chapter 4. 4 What are variables? Variables store values within methods and may change value as the method processes data.
“Unboxing” means taking an Integer object and assigning its value to a primitive int. This is done using the.intValue( ) method. Example; Integer z = new.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 19 A Ray of Sunshine.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Methods. Creating your own methods Java allows you to create custom methods inside its main body. public class Test { // insert your own methods right.
What is Income? What is income? 2 Income is any money you earn plus any other money coming in to you! 3.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Today’s topic: Arithmetic expressions.
Foundations of Programming: Arrays
Computer Science 3 Hobart College
Starting Out with Java: From Control Structures through Objects
Use proper case (ie Caps for the beginnings of words)
Building Java Programs
Error Analysis Runtime Errors.
x/÷ Numbers Year 3-4 – Multiply and divide a multiple of 10
Chapter 3 Introduction to Classes, Objects Methods and Strings
Java: Variables, Input and Arrays
Data Type Conversion ICS2O.
Variables and Constants
Topics to cover Instance variables vs. local variables.
Presentation transcript:

Chapter 2 Practice

Convert pseudocode to Java code Store 20 in the speed variable. Store 10 in the time variable. Multiply speed by time and store the result in the distance variable. Display the contents of the distance variable.

Convert pseudocode to Java code Store 172.5 in the force variable. Store 27.5 in the area variable. Divide area by force and store the result in the pressure variable. Display the contents of the pressure variable.

Write program Write a program that declares the following: A String variable named name An int variable named age A double variable named salary Store your name, age and salary in these variable. The program then displays a message similar to the following: My name is Hoa, my age is 26 and I hope to earn $300 per month.