TO COMPLETE THE FOLLOWING:

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

Introduction to Computer Science Robert Sedgewick and Kevin Wayne Copyright © Recursive GCD Demo public class.
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
Computer Programming Lab(7).
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.1 Chapter 3 Selections.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. Multithreading Example from Liang textbook.
Introduction to C# Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Java Planning our Programs Flowcharts Arithmetic Operators.
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.
תרגול 12 מעקב אובייקטים 1. Our exams material : Course Syllabus : includes all the material.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Control Structures if else do while continue break switch case return for.
1 Linear and Binary Search Instructor: Mainak Chaudhuri
1 Operators and Expressions Instructor: Mainak Chaudhuri
October 28, 2015ICS102: For Loop1 The for-loop and Nested loops.
Peyman Dodangeh Sharif University of Technology Spring 2014.
CS1101X: Programming Methodology Recitation 10 Inheritance and Polymorphism.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Indentation & Readability. What does this program do? public class Hello { public static void main ( String[] args ) { //display initial message System.out.println(
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.
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 45 – 90 seconds per question. Determine the output.
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 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
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.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Output Programs These slides will present a variety of small programs. Most of the programs deal with DecimalFormat objects or Polygon objects. Our concern.
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.
Exercise Java programming
Advanced Programming TA Session 2
using System; namespace Demo01 { class Program
Sum of natural numbers class SumOfNaturalNumbers {
PowerPoint Presentation Authors of Exposure Java
Interface.
Control Structures.
USING ECLIPSE TO CREATE HELLO WORLD
Maha AlSaif Maryam AlQattan
Code Magnets problem for wk5
Building Java Programs
Something about Java Introduction to Problem Solving and Programming 1.
Advanced Programming in Java
הרצאה 3 אלמנטים בסיסיים בשפה
Functions Used to write code only once Can use parameters.
March 29th Odds & Ends CS 239.
PowerPoint Presentation Authors of Exposure Java
Java so far Week 7.
Unit-2 Objects and Classes
Assignment 7 User Defined Classes Part 2
Java Lesson 36 Mr. Kalmes.
Code Animation Examples
Recursive GCD Demo public class Euclid {
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
if-else if (condition) { statements1 } else { statements2
Scope of variables class scopeofvars {
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
PowerPoint Presentation Authors of Exposure Java
Perfect squares class identifySquareButLessClever {
Take out a piece of paper and PEN.
PowerPoint Presentation Authors of Exposure Java
PowerPoint Presentation Authors of Exposure Java
Java Programming with BlueJ Objectives
Scope scope: The part of a program where a variable exists. From its declaration to the end of the { } braces A variable declared in a for loop exists.
Take out a piece of paper and PEN.
PowerPoint Presentation Authors of Exposure Java
Lecture 22: Number Systems
Presentation transcript:

TO COMPLETE THE FOLLOWING: Exposure Java 2013 APCS Edition Chapter 5 Output Slides For Students DO NOT USE DR. JAVA TO COMPLETE THE FOLLOWING:

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 will be with the output of each program, and more importantly, to develop a way to determine program output correctly for programs that involve control structures. You can expect that on quizzes and/or tests only a program segment or a method is shown.

public class Output0501 { public static void main (String args[]) for (int x = 1; x < 8; x++) System.out.println("x = " + x); }

public class Output0502 { public static void main (String args[]) for (int x = 1; x <= 8; x++) System.out.println("x = " + x); }

public class Output0503 { public static void main (String args[]) for (int x = 0; x <= 8; x+=2) System.out.println("x = " + x); }

public class Output0504 { public static void main (String args[]) int x = 0; int y = 0; for (y = 1; y <= 25; y++) y+=5; System.out.println(y); }

public class Output0505 { public static void main (String args[]) int x = 0; int y = 0; for (x = 1; x > 1; x--) y++; System.out.println("y = " + y); }

public class Output0506 { public static void main (String args[]) int x = 0; int y = 0; while (x < 5) y++; x = y; } System.out.println("y = " + y);

public class Output0507 { public static void main (String args[]) int x = 0; int y = 0; while (x < 10) y = x + 2; x = y + 3; } System.out.println("y = " + y);

public class Output0508 { public static void main (String args[]) int x = 0; int y = 0; while (x < 10) y = x * 2; x++; } System.out.println("x = " + x); System.out.println("y = " + y);

public class Output0509 { public static void main (String args[]) int x = 2; while (x < 10) if (x % 2 == 0) x+=2; else x++; } System.out.println("x = " + x);

public class Output0510 { public static void main (String args[]) int x = 2; do if (x % 2 == 0) x+=2; else x++; } while (x < 10); System.out.println("x = " + x);

public class Output0511 { public static void main (String args[]) int x = 10; int y = 20; do x = y + 2; y = x - 2; } while (x < y); System.out.println("x = " + x);

public class Output0512 { public static void main (String args[]) int x = 10; int y = 1; do if (x % 2 == 0) x += 5; else y += 2; } while (y < x); System.out.println("x = " + x);

public class Output0513 { public static void main (String args[]) int x = 1; int y = 3; int z = 5; while (z > x + y) x = y + z; y = x + z; z = x - y; } System.out.println("x = " + x); System.out.println("y = " + y); System.out.println("z = " + z);

public class Output0514 { public static void main (String args[]) int x = 1; int y = 2; int z = 3; for (int k = 1; k <= 10; k++) x = y + z; y = x + z; z = x - y; } System.out.println("x = " + x); System.out.println("y = " + y); System.out.println("z = " + z);

public class Output0515 { public static void main (String args[]) int x = 168; int y = 90; int z = 0; do z = x % y; if (z == 0) System.out.println("y = " + y); else x = y; y = z; } while (z != 0);