Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Read the following code: double number; String result; If (number >= 5) { result = “good” } else { result = “bad” } number = 5.0; System.out.println(result);
Read the following code: double salary, taxrate, income; salary = if (salary >= 3000) { taxrate = 0.30; } else { if (salary >= 2000) { taxrate = 0.20; } else { taxrate = 0.10; } income = salary * (1 - taxrate); System.out.println(income);
Read the following code: double hours, rate, salary; String position = “manager”; hours = 40; If (position.equals(“manager”) || hours > 40) { rate = 80; } else { If (position.equals(“employee”) || hours > 40) { rate = 60; } else { rate = 40; } salary = hours * rate
Read the following code: int result, step; step = 1; result = 20; While (result > 10) { result = result – step; if (step%2 == 0) { step = step - 1; } else { step = step + 1; } System.out.println(result);
Read the following code: int total = 0; for (int index = 1; index < 17; index++) { total = total + 3; } System.out.println(total);
Read the following code: Design a method Parameters: an array of integers - num[]; an integer – rate. The method should return a new array with each element enlarged [rate] times.
Read the following code: Suppose Syracuse University wants to expand student number 1.5% every year. Input the “current student number” and “years”; predict the number of students in the future (years number later).