Review :chapters 1 - 3. What is an algorithm? A step by step description of how to accomplish a task. For example, Adding 3 numbers N1, N2 and N3 Add.

Slides:



Advertisements
Similar presentations
 Draft timetable has the same times as this semester: - ◦ Monday 9:00 am to 12:00 noon, 1:00 pm to 3:00 pm. ◦ Tuesday 9:00 am to 12:00 noon, 1:00 pm.
Advertisements

 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
 To be able to write larger programs ◦ By breaking them down into smaller parts and passing data between the parts.  To understand the concepts of Methods.
LAB 10.
Week 2 - Friday.  What did we talk about last time?  Data representation  Binary numbers  Types  int  boolean  double  char  String.
Computer Programming Lab(5).
Methods and You. Up to this point, I have covered many different data types with you. Variables can be considered the nouns of an English sentence. If.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Lecture 2: Classes and Objects, using Scanner and String.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Week 2 - Wednesday.  What did we talk about last time?  Data representation  Binary numbers  Types  int  boolean  double  char  String.
Chapter 5 Loops.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Input/Output in Java. Output To output to the command line, we use either System.out.print () or System.out.println() or System.out.printf() Examples.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
Can we talk?. In Hello World we already saw how to do Standard Output. You simply use the command line System.out.println(“text”); There are different.
1 Building Java Programs Chapter 5 Lecture 5-1: while Loops, Fencepost Loops, and Sentinel Loops; Procedural Design reading: 5.1 – 5.2; 4.5.
Chapter 5: Control Structures II J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
Chapter 4: Control Structures II
Chapter 5: Control Structures II
COMP Flow of Control: Branching 1 Yi Hong May 19, 2015.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CHAPTER 5 GC 101 Input & Output 1. INTERACTIVE PROGRAMS  We have written programs that print console output, but it is also possible to read input from.
Lecture 2: 1226 Review Tami Meredith. Programming Process How do we fill in the yellow box? Text Editor Compiler (javac) Interpreter (JVM: java) User.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
Java Variables, Types, and Math Getting Started Complete and Turn in Address/Poem.
CONTROL STATEMENTS LOOPS. WHY IS REPETITION NEEDED?  There are many situations in which the same statements need to be executed several times.  Example:
CSCI 1226 FALL 2015 MIDTERM #1 REVIEWS.  Types of computers:  Personal computers  Embedded systems  Servers  Hardware:  I/O devices: mice, keyboards,
1 Class Chapter Objectives Use a while loop to repeat a series of statements Get data from user through an input dialog box Add error checking.
Programming With Java ICS201 University Of Ha’il1 Chapter 11 Recursion.
Martin T. Press.  Main Method and Class Name  Printing To Screen  Scanner.
Lecture 2: 1226 Review II Tami Meredith. Programming Process How do we fill in the yellow box? Text Editor Compiler (javac) Interpreter (JVM: java) User.
 CSC111 Quick Revision. Problem Write a java code that read a string, then show a list of options to the user to select from them, where:  L to print.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Computer Programming Lab 9. Exercise 1 Source Code package excercise1; import java.util.Scanner; public class Excercise1 { public static void main(String[]
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Decisions and Iterations.
Structured Programming Structured Programming is writing a program in terms of only 3 basic control structures: sequence selection repetition We have already.
Java Fundamentals 4. Java Programming: From Problem Analysis to Program Design, Second Edition2 Parsing Numeric Strings  Integer, Float, and Double are.
Intro to Programming STARS College of Communication and Information Florida State University Written by: Hannah Brock Alissa Ovalle Nicolaus Lopez Martin.
Chapter 4: Control Structures I J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second.
CompSci 230 S Programming Techniques
Lecture 2 D&D Chapter 2 & Intro to Eclipse IDE Date.
Chapter 2 Clarifications
CSC111 Quick Revision.
Chapter 2 Basic Computation
Yanal Alahmad Java Workshop Yanal Alahmad
Maha AlSaif Maryam AlQattan
Chapter 5: Control Structures II
Lecture Note Set 1 Thursday 12-May-05
Repetition-Counter control Loop
Chapter 5: Control Structures II
Java Programming: From Problem Analysis to Program Design, 4e
TK1114 Computer Programming
SELECTION STATEMENTS (1)
OUTPUT STATEMENTS GC 201.
Control Statement Examples
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Chapter 2: Basic Elements of Java
Building Java Programs
SELECTION STATEMENTS (2)
Java Variables, Types, and Math Getting Started
CS 200 Loops Jim Williams, PhD.
class PrintOnetoTen { public static void main(String args[]) {
Scope of variables class scopeofvars {
Repetition Statements
Presentation transcript:

Review :chapters 1 - 3

What is an algorithm?

A step by step description of how to accomplish a task. For example, Adding 3 numbers N1, N2 and N3 Add N1 and N2 and store the result in N4. Now add N4 and N3 and store the result in N4 N4 now contains the sum of all 3 numbers

What is the difference between hardware and software?

Hardware : Physical and tangible parts of a computer. Eg, CPU, Memory, Graphics card Software : The non-tangible functionality of the computer. Eg, applications, Operating System, programs

What is the binary equivalent of the following?

What is the binary equivalent of the following?

What is the output of the following? class MyHelloWorldClass { public static void main (String args[]) { System.out.println("Hello " + "World!"); }

What is the output of the following? class MyHelloWorldClass { public static void main (String args[]) { System.out.println("Hello " + "World!"); } Hello World!

What is the output of the following? class Numbers { public static void main (String args[]) { System.out.println("2 + 3 = " ); }

What is the output of the following? class Numbers { public static void main (String args[]) { System.out.println("2 + 3 = " ); } = 23

What is the output of the following? class Numbers{ public static void main (String args[]) { System.out.println("2 + 3 = " + (2 + 3)); }

What is the output of the following? class Numbers{ public static void main (String args[]) { System.out.println("2 + 3 = " + (2 + 3)); } = 5

What are the 3 kinds of errors in programming?

Syntax error System.out..println(“Hello world!”; Logic errors int num1 = 5; int num2 = num1 + 1; int num3 = 5/num2;-> always gives a 0 Runtime errors String str = “5Long”; System.out.println(str.charAt(5)); int zero = 0; System.out.println(0.9 / zero);

What is procedural decomposition?

Breaking a bigger problem into smaller, easier to understand and solve parts.

What is the output of the following? System.out.println("I am \n using \\/\\/ \t escape sequences \"\" here!");

What is the output of the following? System.out.println("I am \n using \\/\\/ \t escape sequences \"\" here!"); I am using \/\/ escape sequences "" here!

What is the output of the following? System.out.println("One"); System.out.print("Two"); System.out.print("Three"); System.out.println("Four"); System.out.print("Five");

What is the output of the following? System.out.println("One"); System.out.print("Two"); System.out.print("Three"); System.out.println("Four"); System.out.print("Five"); One TwoThreeFour Five

What is the output of the following? public static void main (String args[]) { method1(); System.out.println("main"); method2(); } public static void method1() { method2(); System.out.println("method1"); method3(); } public static void method2() { System.out.println("method2"); method3(); } public static void method3() { System.out.println("method3"); }

What is the output of the following? public static void main (String args[]) { method1(); System.out.println("main"); method2(); } public static void method1() { method2(); System.out.println("method1"); method3(); } public static void method2() { System.out.println("method2"); method3(); } public static void method3() { System.out.println("method3"); } method2 method3 method1 method3 main method2 method3

What are some examples of primitive data types?

int boolean char double String and Integer are not primitive data types. They are classes.

What is the output of the following System.out.println(1 + 3 * % 2); System.out.println(1 * 3 * % 2); System.out.println(1 * 3 * % 3); System.out.println(1 / 3 * % 2); System.out.println(1 / 3 * % 3); System.out.println(1 / 3 * 5 + "+" + 5 % 2);

What is the output of the following 1.System.out.println(1 + 3 * % 2);15 2.System.out.println(1 * 3 * % 2);14 3.System.out.println(1 * 3 * % 3);13 4.System.out.println(1 / 3 * % 2);-1 5.System.out.println(1 / 3 * % 3);-2 6.System.out.println(1 / 3 * 5 + "+" + 5 % 2);0+1

What is the output of the following? for (int i = 0; i < 5; i++) { for (int j = 5 - i; j <= 5; j++) { System.out.print("*"); } System.out.println(); }

What is the output of the following? for (int i = 0; i < 5; i++) { for (int j = 5 - i; j <= 5; j++) { System.out.print("*"); } System.out.println(); } * ** *** **** *****

Write code Read in an integer from the user. Let’s say the user enters N as the integer. Now print every Nth char in the string “JASS : Just another silly string”. Example Enter the number N for repeating the Nth char 1 JASS : Just another silly string Enter the number N for repeating the Nth char 3 S:u oeslsi

Write code Read in an integer from the user. Let’s say the user enters N as the integer. Now print every Nth char in the string “JASS : Just another silly string”. public static void main(String[] args) { String jass = "JASS : Just another silly string"; Scanner input = new Scanner (System.in); System.out.println("Enter the number N for repeating the Nth char"); int n = input.nextInt(); for (int i = 1; (i * n -1) < jass.length(); i++) { System.out.print(jass.charAt(i * n - 1)); } input.close(); }

What is the output of the following? String jass = "JASS:JustAnotherSillyString"; System.out.println(jass.length()); System.out.println(jass.substring(2, 5)); System.out.println(jass.substring(3, 7)); System.out.println(jass.substring(0, 0)); System.out.println(jass.substring(10, 15)); System.out.println(jass.substring(15, 21)); System.out.println(jass.substring(25, 27));

What is the output of the following? String jass = "JASS:JustAnotherSillyString"; System.out.println(jass.length());// 27 System.out.println(jass.substring(2, 5));// SS: System.out.println(jass.substring(3, 7));// S:Ju System.out.println(jass.substring(0, 0));// System.out.println(jass.substring(10, 15));// nothe System.out.println(jass.substring(15, 21));// rSilly System.out.println(jass.substring(25, 27));// ng

What is the output? public static void main(String[] args) { int a = 0; int b = 1; int c = 2; System.out.println(method(method(a, b, c), method(b, a,c), method(c, a, b))); } public static int method(int a, int b, int c) { int returnValue = (int)(Math.pow(a,b) + c); System.out.println(returnValue); return returnValue; }

What is the output? public static void main(String[] args) { int a = 0; int b = 1; int c = 2; System.out.println(method(method(a, b, c), method(b, a,c), method(c, a, b))); } public static int method(int a, int b, int c) { int returnValue = (int)(Math.pow(a,b) + c); System.out.println(returnValue); return returnValue; }