Download presentation
Presentation is loading. Please wait.
1
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
2
Information problem… ???
3
Information problem… Input Output
4
Information problem… Input Variable double price, pricewithtax; price = 65.20 price = price*1.0825 pricewithtax = price
5
VariableString String name = “Obama”; String name = “Obama”; int int age = 30; int age = 30; double double price = 15.25; double price = 15.25; boolean boolean dataplan = true; (or false) boolean dataplan = true; (or false) Variable type Variable name (no space, start With alphabet, case sensitive) Variable value
6
Memory Model Values in the process are stored in memory. – View memory as a sequence of slots that can hold values of different types Variables name the slots, sometimes called locations of memory Assignment can put values in variables
7
Standard arithmetic Java supports basic arithmetic operators: +, -, *, /, and %. Add two numbers? int number1, number2, result; numbers1 = 18; number2 = 9; result =number1+number2; System,out.println(result);
8
double x, y; x = 7.486; y = x+15*x-7/x*x; (?????????) System,out.println(y);
9
Exercise: To convert from meters to feet, multiply the number of meters by 3.28084 1.71 meter = ???? Feet 5.68 feet = ???? meter
10
Exercise: Implement the following expression:
11
int number1 = 5; String number2 = “10”; int result; result = number1 + number2; What is the result??? Variable type conversion
12
double number; String str = “10.735”; number = Double.parseDouble(str) StringStringintint str = Integer.toString(num) num = Integer.parseInt(str); StringStringdoubledouble str = Double.toString(num) num = Double.parseDouble(str); Two questions: 1.What is “Double” and “Integer”??? 2. Why we need type conversion???
13
int number1, number2, sum; number1 = Integer.parseInt (jTextField1.getText()); number2 = Integer.parseInt (jTextField2.getText()); sum = number1 + number2; jLabel3.setText(Integer.toString(sum)); jTextField jTextField1.getText( ); jLabel jLabel3.setText (?????);
14
Exercise:
15
1.What is variable? 2.What is expression? 3.What is Standard arithmetic? 4.What is type conversion? 5.What is GUI? 6.How to add the code to GUI?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.