Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Application Programming

Similar presentations


Presentation on theme: "Introduction to Application Programming"— Presentation transcript:

1 Introduction to Application Programming
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu

2 Mario player = new Mario(); //hit a special brick
Mario problem Mario player = new Mario(); //hit a special brick if (player.status.equals(“small”)) { show_mushroom(); } else { show_flower();

3 Mario problem Mario player = new Mario(); //Mario change
if (get_mushroom()) { player.status = “big”; } if (get_flower()){ player.status = “shoot”; if (get_hurt() && player.status.equals(“big”)) { player.status = “small”; if (get_hurt() && player.status.equals(“small”)) { player.status = “die”;

4 Example 1 If your age > 20, serve you wine; else, serve you soda…
int age; String drink; age = ??; if (age > 20) { drink = “wine”; } else { drink = “soda”; System.out.println(drink);

5 System.out.println(result);
Sum of: ……… int result = 0; result = result + 1; result = result + 2; result = result + 3; …… result = result + 100; System.out.println(result);

6 for (int i = 0; i <= 100; i = i + 1) { result = result + i; }
Sum of: ……… int result; result = 0; for (int i = 0; i <= 100; i = i + 1) { result = result + i; } System.out.println(result);

7 Example int i = 1 result = result + i; i ++ yes i <= 100? no
Initialization int i = 1 Loop Body Increment result = result + i; i ++ yes Condition? yes i <= 100? no no

8 result = result + number; } System.out.println(number);
Sum of: ……….. + ??? Result more than 1000 int result = 0; int number = 0; while (result < 1000) { number = number + 1; result = result + number; } System.out.println(number);

9 Compare for (int i = 0; i <= 100; i = i + 1) { result = result + i;
} while (result < 1000) { number = number + 1; result = result + number; }

10 For or While? Compute 25! (factorial)
2. Save $1000 in the bank, interest rate is 3.5%. How many years total = $1800 3. Send messages to your facebook friends automatically


Download ppt "Introduction to Application Programming"

Similar presentations


Ads by Google