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.

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

Java Syntax. Basic Output public class test1 { public static void main(String[] args) { System.out.println("Hello"); }
CSCI1402: Lecture 1 Week 6 Dr. David A. Elizondo Centre for Computational Intelligence School of Computing Office: Gateway 6.61
Minnet (=stacken) public static int fac(int n) { if (n == 0) return 1; else return fac(n-1) * n; }..... main(String [] a) { int x; x = fac(3); System.out.println(x);
If statements Chapter 3. Selection Want to be able to do a statement sometimes, but not others if it is raining, wear a raincoat. Start first with how.
Scoping and Recursion CSC 171 FALL 2001 LECTURE 8.
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
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,
11 Chapter 4 LOOPS AND FILES. 22 THE INCREMENT AND DECREMENT OPERATORS To increment a variable means to increase its value by one. To decrement a variable.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
CSC 204 Programming I Loop I The while statement.
1 Operators and Expressions Instructor: Mainak Chaudhuri
BUILDING JAVA PROGRAMS CHAPTER 1 ERRORS. 22 OBJECTIVES Recognize different errors that Java uses and how to fix them.
CS1101X: Programming Methodology Recitation 10 Inheritance and Polymorphism.
 The if statement and the switch statement are types of conditional/decision controls that allow your program.  Java also provides three different looping.
Repetition Statements while and do while loops
Software Engineering 4, Julian Richardson, 30 April Static Analysis Software Engineering HX3 Julian Richardson
Indentation & Readability. What does this program do? public class Hello { public static void main ( String[] args ) { //display initial message System.out.println(
Introduction to Computing Concepts Note Set 15. JOptionPane.showMessageDialog Message Dialog Allows you to give a brief message to the user Can be used.
Review TEST 2 Chapters 4,5,7. QUESTION For which type of operands does the == operator always work correctly: (a) int, (b) double, or (c) String?
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.
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.
Review :chapters 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.
Java Review if Online Time For loop Quiz on Thursday.
CSCI S-1 Section 4. Deadlines for Homework 2 Problems 1-8 in Parts C and D – Friday, July 3, 17:00 EST Parts E and F – Tuesday, July 7, 17:00 EST.
Computer Science 320 A First Program in Parallel Java.
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
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
CS001 Introduction to Programming Day 6 Sujana Jyothi
CS1101X: Programming Methodology Recitation 10 Inheritance and Polymorphism.
AP Examination Alert The APCS Examination includes a variety of Boolean Logic questions. Many questions require indirect knowledge of Boolean Logic, and.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING While Loop.
WAP to find out the number is prime or not Import java.util.*; Class Prime { public static void main(string args[]) { int n,I,res; boolean flag=true;
Output Programs These slides will present a variety of small programs. Most of the programs deal with DecimalFormat objects or Polygon objects. Our concern.
Computer Science I Lab 1 ISMAIL ABUMUHFOUZ | CS 180.
George Boole A century ago there was a mathematician, George Boole, who took statements and wrote them in a precise format, such that a statement is.
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.
Variable scope. Variable Scope Variables do not live forever. Failing to take that into account leads to problems. Let's look at an example. Let's write.
Chapter 2 Clarifications
Exercise Java programming
Advanced Programming TA Session 2
using System; namespace Demo01 { class Program
Sum of natural numbers class SumOfNaturalNumbers {
Introduction to programming in java
Building Java Programs
Advanced Programming in Java
Building Java Programs
Decision statements. - They can use logic to arrive at desired results
TO COMPLETE THE FOLLOWING:
PowerPoint Presentation Authors of Exposure Java
Java so far Week 7.
Propositional Equivalences Rosen 5th and 6th Editions section 1.2
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.
Scope of variables class scopeofvars {
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
while while (condition) { statements }
PowerPoint Presentation Authors of Exposure Java
PowerPoint Presentation Authors of Exposure Java
PowerPoint Presentation Authors of Exposure Java
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.
PROGRAM FLOWCHART Iteration Statements.
PowerPoint Presentation Authors of Exposure Java
CIS 110: Introduction to Computer Programming
Instructor: Mainak Chaudhuri
Presentation transcript:

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 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 contain compound conditions. 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 Output1001 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; if (x z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1002 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; if (x z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1003 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; if (x < y && y < z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1004 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; if (x < y || y < z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1005 { public static void main(String args[]) { int x = 10; int y = 20; int z = 20; if (x == y || y == z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1006 { public static void main(String args[]) { int x = 10; int y = 20; int z = 20; if (x == y && y == z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1007 { public static void main(String args[]) { int x = 20; int y = 20; int z = 20; if (x == y && y == z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1008 { public static void main(String args[]) { int x = 20; int y = 20; int z = 20; if (x == y || y == z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1009 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; if (x == y || y == z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1010 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; if (x == y && y == z) System.out.println("Hello"); else System.out.println("Goodbye"); }

public class Output1011 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; while (x < y && y < z) { x++; z--; } System.out.println(x); System.out.println(y); System.out.println(z); }

public class Output1012 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; while (x < y || y < z) { x+=3; z-=2; } System.out.println(x); System.out.println(y); System.out.println(z); }

public class Output1013 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; while (x < y && y != z) { x*=2; z--; } System.out.println(x); System.out.println(y); System.out.println(z); }

public class Output1014 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; while (x < y || y != z) { x*=2; z-=5; } System.out.println(x); System.out.println(y); System.out.println(z); }

public class Output1015 { public static void main(String args[]) { int x = 10; int y = 20; int z = 30; while (x + y z) { x*=2; z-=5; } System.out.println(x); System.out.println(y); System.out.println(z); }