CS 106 Introduction to Computer Science I 01 / 29 / 2008 Instructor: Michael Eckmann.

Slides:



Advertisements
Similar presentations
CS 206 Introduction to Computer Science II 09 / 05 / 2008 Instructor: Michael Eckmann.
Advertisements

CS 206 Introduction to Computer Science II 04 / 01 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 01 / 20 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 04 / 28 / 2009 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 18 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 09 / 14 / 2009 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 09 / 13 / 2006 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 01 / 21 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 02 / 20 / 2009 Instructor: Michael Eckmann.
Using JOptionPanes for graphical communication with our programs. Pages Horstmann 139.
CS 106 Introduction to Computer Science I 09 / 14 / 2007 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 09 / 04 / 2008 Instructor: Michael Eckmann.
Mathematical Operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming in.
CS 102 Computers In Context (Multimedia)‏ 02 / 02 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 01 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 09 / 17 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 21 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 25 / 2008 Instructor: Michael Eckmann.
Introduction to Computers and Programming Lecture 3: Variables and Input Professor: Evan Korth New York University.
CS 106 Introduction to Computer Science I 03 / 26 / 2008 Instructor: Michael Eckmann.
School of Computing Science CMT1000 © Ed Currie Middlesex University Lecture 10: 1 TEST!!
CS 106 Introduction to Computer Science I 02 / 11 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 27 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 22 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 10 / 04 / 2006 Instructor: Michael Eckmann.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
School of Computing Science CMT1000 © Ed Currie Middlesex University Lecture 3: 1 CMT1000: Introduction to Programming Ed Currie Lecture 3: Program structure.
CS 106 Introduction to Computer Science I 11 / 08 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 30 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 20 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 10 / 09 / 2006 Instructor: Michael Eckmann.
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
CS 106 Introduction to Computer Science I 03 / 08 / 2010 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 04 / 09 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 24 / 2010 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 19 / 2008 Instructor: Michael Eckmann.
CS 102 Computers In Context (Multimedia)‏ 03 / 25 / 2009 Instructor: Michael Eckmann.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
CS 206 Introduction to Computer Science II 01 / 23 / 2009 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 19 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 23 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 09 / 28 / 2007 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 09 / 19 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 04 / 07 / 2010 Instructor: Michael Eckmann.
JOptionPane class. Dialog Boxes A dialog box is a small graphical window that displays a message to the user or requests input. A variety of dialog boxes.
Introduction To Object-Oriented Programming. Object-Oriented Programming Class: Code that defines the behavior of a Java programming element called an.
CS 330 Programming Languages 11 / 21 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 01 / 31 / 2007 Instructor: Michael Eckmann.
CS 330 Programming Languages 11 / 13 / 2008 Instructor: Michael Eckmann.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
CS 206 Introduction to Computer Science II 09 / 11 / 2009 Instructor: Michael Eckmann.
Dialog Boxes.
CS 106 Introduction to Computer Science I 09 / 26 / 2007 Instructor: Michael Eckmann.
Introduction to Computing Concepts Note Set 15. JOptionPane.showMessageDialog Message Dialog Allows you to give a brief message to the user Can be used.
Strings and I/O. Lotsa String Stuff… There are close to 50 methods defined in the String class. We will introduce several of them here: charAt, substring,
CS 106 Introduction to Computer Science I 03 / 22 / 2010 Instructor: Michael Eckmann.
GCSE Computing: Programming GCSE Programming Remembering Python.
CS 106 Introduction to Computer Science I 09 / 10 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 10 / 10 / 2007 Instructor: Michael Eckmann.
AP Java 10/1/2015. public class Rolling { public static void main( String [] args) public static void main( String [] args) { int roll; int roll; for.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
Input and Output Upsorn Praphamontripong CS 1110
2.5 Another Java Application: Adding Integers
Use proper case (ie Caps for the beginnings of words)
JOptionPane class.
F II 2. Simple Java Programs Objectives
CS 1111 Introduction to Programming Spring 2019
Presentation transcript:

CS 106 Introduction to Computer Science I 01 / 29 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS Spring 2008 Today’s Topics Comments and/or Questions? arithmetic operators relational operators if/else statements compound statements import user input using JOptionPane psuedocode

javax.swing.JOptionPane Contains methods to show dialog boxes. JOptionPane.showMessageDialog displays messages in a dialog box. JOptionPane.showInputDialog allows for user input in a dialog box. Nicer to use than reading from / printing to the console screen. Michael Eckmann - Skidmore College - CS Spring 2008

JoptionPane class for I/O showMessageDialog takes two parameters, the first of which should always be null for now. The second is a String that should be outputted. showInputDialog takes one parameter which is a String that displays --- it should tell the user what to enter. The user's input is returned as a String. Michael Eckmann - Skidmore College - CS Spring 2008

JoptionPane class for I/O Example usage: import javax.swing.JOptionPane; // need this line above your class String input_string; // variable to store the user's input JOptionPane.showMessageDialog(null, “Hey”); input_string = JOptionPane.showInputDialog(“Enter something.”); Michael Eckmann - Skidmore College - CS Spring 2008

javax.swing.JOptionPane Let’s write Hello World using a message dialog box instead of System.out.println. Michael Eckmann - Skidmore College - CS Spring 2008

Pseudocode pseudocode is an informal use of English to describe what a program is to do and in what order pseudocode is not an actual computer programming language it is used prior to writing actual code to help the programmer in the planning stages of a program Michael Eckmann - Skidmore College - CS Spring 2008

Example Application Exercise write a program to compute the number of projected home runs a baseball player will hit for the season based on how many homers he’s hit so far. Output should look like: player’s name is projected to hit number home runs in 162 games. Any ideas? Michael Eckmann - Skidmore College - CS Spring 2008

Pseudocode for our example get player’s name from the user get the number of homeruns so far get the number of games played so far compute the number of projected homeruns for this player based on a season of 162 games by using the following calculation projected homers homers so far = games played so far Michael Eckmann - Skidmore College - CS Spring 2008

Pseudocode for our example (continued)‏ from this equation, projected homers homers so far = games played so far we can multiply both sides of the equation by 162 and get projected homers = homers so far * 162 / games played so far Michael Eckmann - Skidmore College - CS Spring 2008

Pseudocode for our example (continued)‏ Print out the following with actual values for player’s name and number player’s name is projected to hit number home runs in 162 games. Pseudocode could be more fleshed out than what we have done here --- use as much or as little detail in pseudocode as you prefer. Michael Eckmann - Skidmore College - CS Spring 2008

Pseudocode for our example (continued)‏ Now we can write the program based on our pseudocode. Michael Eckmann - Skidmore College - CS Spring 2008