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

Review of Math Class Methods abssqrt minmax powround ceilfloor.
OOP & JAVA. HelloWorld.java /** * The HelloWorld class is an application that * displays "Hello World!" to the standard output. */ public class HelloWorld.
Unit 071 Review of Applets Learning Outcomes oDistinguish between Java Applications and Java Applets. oWrite applet programs that can load images and play.
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,
© 2007 Lawrenceville Press Slide 1 Chapter 2 HTML An example HTML document Hello world!
Applets.
Learn about the types of Graphics that are available Develop a basic Graphics applet Develop a basic Graphics application Review the Java API and use.
9/21/99www.cs.vt.edu/wwtut/1 User Interface Programming In Java Part 1 – Introduction Marc Abrams Virginia Tech CS Dept courses.cs.vt.edu/wwwtut/
Review of Math Class Methods abssqrt minmax powround ceilfloor.
Java Keywords  Reserved Words Part of the Java language Examples: public, static, void  Pre-defined Java Identifiers Defined in Java Libraries Examples:
// Java0802.java // CardDeck Case Study #02 // Variables, called attributes or data fields, are added to the class. public class Java0802 { public static.
Abstract Window Toolkit (AWT) The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include:  A rich set.
// Java0601.java // This program demonstrates that the methods of a class are not always // accessible, like they were with the class. In this case an.
Exposure Java-A 2006 Chapter 4 Slides Using Methods and Parameters
***** SWTJC STEM ***** Chapter 3-1 cg 39 Math Class The Math class provides a convenient way to access higher math functions. The Math class is automatically.
Primitive Data Types vs. Classes A simple/primitive data type can store only one single value. This means an int can only store one integer. A double.
Inheritance Inheritance is the process of using features (both attributes and methods) from an existing class. The existing class is called the superclass.
Object Oriented Programming (OOP) is a style of programming that incorporates these 3 features: Encapsulation Polymorphism Class Interaction.
1 Windows program example import java.awt.*; import java.awt.event.*; public class wpexample extends Frame { public wpexample(String title) { super(title);
Lec 16 Adding Mouse and KeyEvent handlers to an Applet Class.
Java Applet Basics (2). The Body Mass Index Calculator.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Review of Math Class Methods abssqrt minmax powround ceilfloor.
Visual Classes 1 Class: Bug 5 Objects: All Bug Objects.
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.
Exposure Java 2011 APCS Edition
Chapter 2 Creating a Java Application and Applet.
Agenda March 8 1.PowerPoint Presentation on Variables. For download:
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.
Chapter 10 Arrays. Learning Java through Alice © Daly and Wrigley Objectives Declare and use arrays in programs. Access array elements within an array.
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
CSI 3125, Preliminaries, page 1 Adapter Class. CSI 3125, Preliminaries, page 2 Adapter Class Java provides a special feature, called an adapter class,
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.
Lec 15 Writing an Applet Class. Agenda Writing an Applet class Java Graphics class.
Output Programs These slides will present a variety of small programs. Most of the programs deal with DecimalFormat objects or Polygon objects. Our concern.
Java Applets Getting Started. Import Files In order to run the applet properly, we have to import some files into our class. These files are: –import.
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.
Review of Math Class Methods abssqrt minmax powround ceilfloor.
Object Oriented Programming (OOP) is a style of programming that incorporates these 3 features: Encapsulation Polymorphism Class Interaction.
Exposure Java 2011 APCS Edition
User Interface Programming In Java
Monday 26th May Java Lecture 10 Overview
Exposure Java 2013 APCS Edition
PowerPoint Presentation Authors of Exposure Java
PowerPoint Presentation From Materials Created
PowerPoint Presentation Authors of Exposure Java
Exposure Java 2013 APCS Edition Chapter 12 Slides Focus on OOP:
PowerPoint Presentation Authors of Exposure Java
Systems of Computation
Section 6.2 Classes & Objects.
TO COMPLETE THE FOLLOWING:
Exposure Java 2015 Pre-AP®CS Edition Chapter 12 Slides String Methods
Package & Java Access Specifiers
PowerPoint Presentation Authors of Exposure Java
Exposure Java 2015 AP®CS Edition
PowerPoint Presentation Authors of Exposure Java
Data Types, Concatenation, PEMDAS, Shortcuts, and Comments
Java Lesson 36 Mr. Kalmes.
Section 9.1 Introduction.
Section 6.2 Classes & Objects.
Take out a piece of paper and PEN.
class PrintOnetoTen { public static void main(String args[]) {
PreAP Computer Science Review Quiz 08
PowerPoint Presentation Authors of Exposure Java
PowerPoint Presentation Authors of Exposure Java
PowerPoint Presentation Authors of Exposure Java
Debugging Exercise 00 Try compiling the code samples.
Presentation transcript:

PowerPoint Presentation Authors of Exposure Java APCS Edition Chapter 6 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 demonstrates a feature 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, which involves control structures. 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.

import java.text.DecimalFormat; public class Output0601 { public static void main (String args[]) DecimalFormat output = new DecimalFormat("0000"); int x = 1; int y = 21; int z = 321; System.out.println(output.format(x)); System.out.println(output.format(y)); System.out.println(output.format(z)); }

import java.text.DecimalFormat; public class Output0602 { public static void main (String args[]) DecimalFormat output = new DecimalFormat("0000"); int a = 1; int b = 21; int c = 321; int d = 4321; int e = 54321; System.out.println(output.format(a)); System.out.println(output.format(b)); System.out.println(output.format(c)); System.out.println(output.format(d)); System.out.println(output.format(e)); }

import java.text.DecimalFormat; public class Output0603 { public static void main (String args[]) DecimalFormat output = new DecimalFormat("0000"); int a = 10; int b = a + 25; int c = b * 2; int d = a + b + c; int e = d / 5; System.out.println(output.format(a)); System.out.println(output.format(b)); System.out.println(output.format(c)); System.out.println(output.format(d)); System.out.println(output.format(e)); }

import java.text.DecimalFormat; public class Output0604 { public static void main (String args[]) DecimalFormat output = new DecimalFormat("0,000"); int a = 100; int b = a * 25; int c = b * 2; int d = a + b + c; int e = d / 5; System.out.println(output.format(a)); System.out.println(output.format(b)); System.out.println(output.format(c)); System.out.println(output.format(d)); System.out.println(output.format(e)); }

import java.text.DecimalFormat; public class Output0605 { public static void main (String args[]) DecimalFormat money = new DecimalFormat("$0.00"); double hoursWorked = 42; double hourlyRate = 9.75; double grossPay = hoursWorked * hourlyRate; double deductions = grossPay * 0.299; double netPay = grossPay - deductions; System.out.println(money.format(grossPay)); System.out.println(money.format(deductions)); System.out.println(money.format(netPay)); }

import java.awt.*; import java.applet.*; public class Output0606 extends Applet { public void paint(Graphics g) Expo.setColor(g,Expo.red); Polygon z = new Polygon(); z.addPoint(100,200); z.addPoint(300,100); z.addPoint(500,100); z.addPoint(700,200); z.addPoint(700,300); z.addPoint(500,400); z.addPoint(300,400); z.addPoint(100,300); g.drawPolygon(z); } The grid below is 800 X 500. Each square is 100 X 100. For the remaining questions if you have a tablet PC try to draw the output on the grid.

import java.awt.*; import java.applet.*; public class Output0607 extends Applet { public void paint(Graphics g) Expo.setColor(g,Expo.red); Polygon z = new Polygon(); z.addPoint(100,200); z.addPoint(300,100); z.addPoint(500,100); z.addPoint(700,200); z.addPoint(700,300); z.addPoint(500,400); z.addPoint(300,400); z.addPoint(100,300); }

import java.awt.*; import java.applet.*; public class Output0608 extends Applet { public void paint(Graphics g) Expo.setColor(g,Expo.red); Polygon z = new Polygon(); z.addPoint(100,200); z.addPoint(300,100); z.addPoint(500,100); z.addPoint(700,200); z.addPoint(700,300); z.addPoint(500,400); z.addPoint(300,400); z.addPoint(100,300); g.fillPolygon(z); }

import java.awt.*; import java.applet.*; public class Output0609 extends Applet { public void paint(Graphics g) Expo.setColor(g,Expo.red); Polygon z = new Polygon(); z.addPoint(300,400); z.addPoint(300,100); z.addPoint(700,300); z.addPoint(100,300); z.addPoint(500,100); z.addPoint(500,400); z.addPoint(100,200); z.addPoint(700,200); g.drawPolygon(z); }

import java.awt.*; import java.applet.*; public class Output0610 extends Applet { public void paint(Graphics g) g.setColor(Color.red); Font font = new Font("Arial",Font.BOLD,36); g.setFont(font); g.drawString("Hello",100,100); g.drawString("all",600,400); g.drawString("you",600,100); g.drawString("happy",100,400); g.drawString("people.",350,250); }