Introduction to Computing Concepts Note Set 11. Other ways of interacting with Java programs There are: ▫ GUI programs ▫ Web-based applets (GUI programs.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Chapter 8 Improving the User Interface
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
Intro Programming By Trevor Decker Team 1743 By Trevor Decker Team 1743.
IT151: Introduction to Programming
University of Palestine software engineering department Introduction to data structures Introduction to java application instructor: Tasneem Darwish.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
Computer Science 1620 Programming & Problem Solving.
Chapter 7 Improving the User Interface
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 6.1 Test-Driving the Wage Calculator Application.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Java Programming, Second Edition Chapter Four Advanced Object Concepts.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
The NetBeans IDE CSIS 3701: Advanced Object Oriented Programming.
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Enhancing the Wage Calculator Application Introducing Function Procedures and.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 7.1 Test-Driving the Wage Calculator Application.
Sales person receive RM200/week plus 9% of their gross sales for that week. Write an algorithms to calculate the sales person’s earning from the input.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
The Java Programming Language
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright © Curt Hill Java Looking at our first console application in Eclipse.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Programming Concept Chapter I Introduction to Java Programming.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Chapter 2: Java Fundamentals
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Introduction to Computing Concepts Note Set 12. Writing a Program from Scratch public class SampleProgram1 { public static void main (String [] args)
Creating a Java Application and Applet
Introduction to Programming Python Lab 5: Strings and Output 05 February PythonLab5 lecture slides.ppt Ping Brennan
Introduction to Programming
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
Introduction to Java Import Scanner class to use in our program
Development Environment
Introduction to Programming and Visual Basic
Introduction to Classes and Objects
Yanal Alahmad Java Workshop Yanal Alahmad
User input We’ve seen how to use the standard output buffer
Java Programming with BlueJ
Introduction to Programming
An Introduction to Java – Part I, language basics
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Introduction CSC 111.
Java Intro.
Chapter 2 Programming Basics.
CS360 Client/Server Programming Using Java
The keyboard is the standard input device.
Let’s all Repeat Together
Java Programming with BlueJ Objectives
Unit 3: Variables in Java
Presentation transcript:

Introduction to Computing Concepts Note Set 11

Other ways of interacting with Java programs There are: ▫ GUI programs ▫ Web-based applets (GUI programs that run in a browser) ▫ Command line interface programs  Windows Based: Run in command prompt/Dos prompt  From a RUN dialog, type ‘cmd’ and hit enter  Macs or Linux: Run in a Terminal Window  Mac: Look in Utilities in applications  Linux: depends on distro – look under accessories on “main menu”

On Windows 4mac-terminal.png Windows Command Prompt Mac OS X Terminal

System.out.println(…) Used in CLI program Can be used in gui program for debugging purposes Accepts a String argument and will print it Prints the argument then goes to the next line (new line) Examples: System.out.println (“Hello World”); System.out.println(“What” + “ is “ + “ your name?”); System.out.println(“Hello” + 123); Hello World What is your name? Hello123 Hello World What is your name? Hello123

System.out.println() We’ll use this to do some quick testing in Java Can be used to write fully-operational complex pieces of software In Netbeans, output will appear in the Terminal Output Window at the bottom

System.out.println(…) – some notes System.out.println(“Hello “ + “world.”); System.out.println(“Grade:” + 97);

On Slides: To Save Space on Slides: print (…); means System.out.println(…);

Back to ifs… What’s the difference between… this… if ( grade >= 90 ) print(“A”); if ( grade >= 80 ) print (“B”); if (grade >= 70 ) print (“C”); and this… if ( grade >= 90 ) print(“A”); else if ( grade >= 80 ) print (“B”); else if (grade >= 70 ) print (“C”);

Nesting Control Statements Nested – ifs ▫ having one if statement inside another if (a > b) { if (b < c) { print(“cool”); } print (“awesome”); } Will be executed if b Will be executed if a > b regardless of truth of b < c

Nesting Control Statements if (a > b) { if (b < c) { print(“cool”); } print (“awesome”); } Assume: a = 3, b = 2, c = 25. Output: _____________________________ a = 4, b = 6, c = 8. Output: ______________________________ a = 4, b = -2, c = -9. Output: ______________________________

Decimal Format Some contexts have floating point values but only with a certain amt of precision ▫ MONEY!!!!!! Use a DecimalFormat object to help format how FP data is displayed double wages = ; DecimalFormat dollars = new DecimalFormat(“$0.00”); myJLabel.setText(dollars.format(wages));

Constants Store a constant value. Uses keyword final to declare final int PI = ; If an attempt is made to change the value, compiler will indicate an error Makes reading source code easier. If constant changes, only have to change in one place. ▫ Think sales tax rate or commission rate for a job. ▫ Could use many places but when changes, only change in one place

Wage Calculator: Example Application Requirements A company needs an application that calculates the gross wages per week for each of its employees. Each employee’s weekly salary is based on the employee’s number of hours worked and hourly wage. A standard work week is 40 hours. Any time worked over 40 hours in a week is considered “overtime,” and employees earn time-and-a-half for the extra hours. Create an application that accepts one employee’s number of hours worked and hourly wage, and calculates the employee’s total (gross) wages for the week.

private void calcualteJButtonActionPerformed(ActionEvent event) { //Get Data from text fields

//Declare constant and determine over time using ifs

//Format and display data