PowerPoint Presentation Authors of Exposure Java

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Copyright 2010 by Pearson Education Building Java Programs Chapter 7 Lecture 7-2: Arrays as Parameters reading: , 3.3 self-checks: Ch. 7 #5, 8,
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 19: Heap Sort.
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Do You Understand Methods and Parameters? In this section you will be shown 25 different programs. Most of these programs have some type of error. A few,
Computer Programming Lab(5).
1 Linear and Binary Search Instructor: Mainak Chaudhuri
First Data Structure Definition A data structure is a data type whose components are smaller data structures and/or simple data types.
Java Arrays and Methods MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh.
The Bubble Sort by Mr. Dave Clausen La Cañada High School.
Output Programs These slides will present a variety of small programs. Each program has a control structure that was introduced in this chapter. Our concern.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Output Programs These slides will present a variety of small programs. Each program has some type of array that was introduced in this chapter. Our concern.
1 Insertion sort [ ] i=1 j=1 i=2 j=2 insert i=3 at j=1 [ ] i=3 j=1 insert i=4 at j=0 [
1 BUILDING JAVA PROGRAMS CHAPTER 7.2 ARRAY TRAVERSAL ALGORITHMS.
Java Methods 11/10/2015. Learning Objectives  Be able to read a program that uses methods.  Be able to write a write a program that uses methods.
PreAP Computer Science Quiz Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 30 – 60 seconds.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Output Programs These slides will present a variety of small programs. Each program has a compound condition which uses the Boolean Logic that was introduced.
Output Programs These slides will present a variety of small programs. Most of the programs deal with DecimalFormat objects or Polygon objects. Our concern.
Array Review Selection Sort Get out your notes.. Learning Objectives Be able to dry run programs that use arrays Be able to dry run programs that use.
Output Programs These slides will present a variety of small programs. Each program has a control structure that was introduced in this chapter. Our concern.
Exposure Java 2011 APCS Edition
MC Question Strategies
PowerPoint Presentation Authors of Exposure Java
Exercise Java programming
Advanced Programming TA Session 2
using System; namespace Demo01 { class Program
PowerPoint Presentation Authors of Exposure Java
More on Recursion.
Sorting Algorithms: Selection, Insertion and Bubble
Data Structures Array - Code.
Array Review Selection Sort
CSS161: Fundamentals of Computing
March 29th Odds & Ends CS 239.
Mr. Dave Clausen La Cañada High School
TO COMPLETE THE FOLLOWING:
Adapted from slides by Marty Stepp, Stuart Reges & Allison Obourn.
An Introduction to Java – Part I, language basics
Exposure Java 2015 Pre-AP®CS Edition Chapter 12 Slides String Methods
PowerPoint Presentation Authors of Exposure Java
AP Java Warm-up Boolean Array.
Lecture 9 Objectives Learn about arrays.
CSE 143 Lecture 11 Recursive Programming slides created by Marty Stepp
Java Lesson 36 Mr. Kalmes.
Data Structures Array - Code.
CS2011 Introduction to Programming I Methods (II)
class PrintOnetoTen { public static void main(String args[]) {
slides created by Ethan Apter
Module 4 Loops and Repetition 4/7/2019 CSE 1321 Module 4.
Java Programming: Chapter 9: Recursion Second Edition
Dry Run Practice Use Methods with an Insertion Sort
Object Oriented Programming
Merging two sorted arrays
PowerPoint Presentation Authors of Exposure Java
Take out a piece of paper and PEN.
Take out a piece of paper and PEN.
PowerPoint Presentation Authors of Exposure Java
Take out a piece of paper and PEN.
CSS161: Fundamentals of Computing
Take out a piece of paper and PEN.
CSE 143 Lecture 2 ArrayIntList, binary search
slides created by Ethan Apter
Question 1a) What is printed by the following Java program? int s;
Outline Declaring and Using Arrays Arrays of Objects
PowerPoint Presentation Authors of Exposure Java
Array Review Selection Sort
Lecture 22: Number Systems
Presentation transcript:

PowerPoint Presentation Authors of Exposure Java AP®CS Edition Chapter 11 Output Slides For Students PowerPoint Presentation created by: Mr. John L. M. Schram and Mr. Leon Schram Authors of Exposure Java

Output Programs These slides will present a variety of small programs. Each program has some type of array that was introduced in this chapter. Our concern will be with the output of each program, and more importantly, develop some methods to determine program output correctly, for programs that involves arrays. You can expect that on quizzes and/or tests only a program segment or a method is shown.

Teacher/Student Versions, Tablet PCs, and Inking The “For Teachers” version of this presentation has 2 slides for each program. The first slide only shows the program. The second shows the program, worked out solution, and output. The “For Students” version only has 1 slide for each program with no provided solution or output. Students are expected to work out the solutions either on paper, or ideally they can “ink” directly on their laptops.

public class Ex1101 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; System.out.println(list[1]); }

public class Ex1102 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; for (int index = 1; index <= 9; index++) System.out.println(list[index]); }

public class Ex1103 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; for (int index = 0; index < 9; index++) System.out.println(list[index]); }

public class Ex1104 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1105 { public static void main (String args[]) int list[] = new int[10]; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1106 { public static void main (String args[]) int list[] = new int[10]; list[0] = 9999; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1107 { public static void main (String args[]) int list[] = new int[10]; list[1] = list[3] = list[5] = list[7] = list[9] = 9999; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1108 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; list[1] = list[3] = list[5] = list[7] = list[9] = 9999; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1109 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; list[1] = list[3] = list[5] = list[7] = 9999; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1110 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; list[1] = list[3]; list[5] = list[7]; list[8] = list[6]; list[2] = list[0]; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1111 { static int list[] = {11,99,22,88,33,77,44,66,55}; public static void main (String args[]) swap(3,1); swap(7,5); swap(6,8); swap(0,2); displayArray(); } public static void swap(int a, int b) list[a] = list[b]; list[b] = list[a]; public static void displayArray() // Precondition: list is a non-empty Java static array of integers System.out.print("[" + list[0]); for (int index = 1; index < list.length; index++) System.out.print(", " + list[index]); System.out.println("]");

public class Ex1112 { static int list[] = {11,99,22,88,33,77,44,66,55}; public static void main (String args[]) swap(3,1); swap(7,5); swap(6,8); swap(0,2); displayArray(); } public static void swap(int a, int b) int temp = list[a]; list[a] = list[b]; list[b] = temp; public static void displayArray() // Precondition: list is a non-empty Java static array of integers System.out.print("[" + list[0]); for (int index = 1; index < list.length; index++) System.out.print(", " + list[index]); System.out.println("]");

public class Ex1113 { public static void main (String args[]) int list[] = new int[10]; qwerty(list,5); displayArray(list); } public static void qwerty(int array[], int item) for (int index = 0; index < array.length; index++) array[index] = item; public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1114 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; qwerty(list,5); displayArray(list); } public static void qwerty(int array[], int item) for (int index = 0; index < array.length; index++) array[index] = item; public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1115 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; qwerty(list,5); list[5] = 9999; displayArray(list); } public static void qwerty(int array[], int item) for (int index = 0; index < array.length; index++) array[index] = item; public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1116 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; list[1] = list[2] + list[0]; list[8] = list[7] + list[6]; list[5] = list[8] - list[1]; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1117 { public static void main (String args[]) int list1[] = {11,99,22,88,33,77,44,66,55}; int list2[] = new int[100]; System.out.println(list1.length); System.out.println(list2.length); }

public class Ex1118 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; for(int index = 0; index < list.length; index++) list[index]++; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1119 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; list[1] = list[2] + list[0]; int x = 1; if (list[1] == list[4]) x = 11; for(int index = 0; index < list.length; index++) list[index] /= x; displayArray(list); } public static void displayArray(int array[]) // Precondition: array is a non-empty Java static array of integers System.out.print("[" + array[0]); for (int index = 1; index < array.length; index++) System.out.print(", " + array[index]); System.out.println("]");

public class Ex1120 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; System.out.println(list[list.length]); }

public class Ex1121 { public static void main (String args[]) int list[] = {11,99,22,88,33,77,44,66,55}; System.out.println(list[list.length - 1]); }