Lab Exponential Function
Lab average income by gender
Advance notice
星期五, 10月 26, 2007
Lab Exponential Function
Do Project 7 of Chap. 3. (2nd ed. & 3rd ed.) or Project 4 (1st ed.)
Hint: You don't have to use nested loops.
Hint: You don't have to use nested loops.
11-9-2007 Quiz 2
Scope: Chap 3
Format: Open book. Pencil & Paper.
Running time: 30 min.
預告: 11/23 期中考週不上課。
Format: Open book. Pencil & Paper.
Running time: 30 min.
預告: 11/23 期中考週不上課。
Average income by gender
Write a program to calculate average income by gender based on the following data, where F stands for female and M for male.
F 62,000
M 25,000
F 38,000
F 43,000
M 65,000
M 120,000
F 80,000
M 30,100
You should be able to allow users to type in a whole line such as F 80,000 followed by next line M 30,100.
Without any change made to your program, your program should be able to process a new set of data, such as follows:
M 52,000
M 35,000
F 48,000
M 33,000
F 75,000
F 110,000
F 90,000
M 30,100
F 62,000
M 25,000
F 38,000
F 43,000
M 65,000
M 120,000
F 80,000
M 30,100
You should be able to allow users to type in a whole line such as F 80,000 followed by next line M 30,100.
Without any change made to your program, your program should be able to process a new set of data, such as follows:
M 52,000
M 35,000
F 48,000
M 33,000
F 75,000
F 110,000
F 90,000
M 30,100
Lab 9*9
Write a program to generate the following table of arithmetic expressions
1*1=1 1*2=2 1*3=3 ... 1*9=9
2*1=2 2*2=4 2*3=6 ... 2*9=19
...
9*1=9 9*2=18 9*3=27 ... 9*9=81
1*1=1 1*2=2 1*3=3 ... 1*9=9
2*1=2 2*2=4 2*3=6 ... 2*9=19
...
9*1=9 9*2=18 9*3=27 ... 9*9=81
Lab Fibonacci numbers
Do Project 3.3 (1st ed.) or Project 6 (2nd ed. & 3rd ed.) Fibonacci numbers.
List the first 100 numbers and the ratio of
a number to its previous number, such as 1/1 = 1, 2/1 = 2, 3/2 = 1·5, 5/3 = 1·666..., 8/5 = 1·6, 13/8 = 1·625, 21/13 = 1·61538....
Want to know more about Fibonacci number
List the first 100 numbers and the ratio of
a number to its previous number, such as 1/1 = 1, 2/1 = 2, 3/2 = 1·5, 5/3 = 1·666..., 8/5 = 1·6, 13/8 = 1·625, 21/13 = 1·61538....
Want to know more about Fibonacci number
星期五, 10月 12, 2007
Homework 10-12-2007: Finding the max and the min
Based on your study of Display 3.8, write a code to find the max and min of a list of number.
For example, given 1,3,5, and9, the max is 9 and the min is 1.
Your program should be able to process a list of any length.
For example, given 1,3,5, and9, the max is 9 and the min is 1.
Your program should be able to process a list of any length.
Lab Finding the max of three numbers
Write a program to decide the max number of the three input number.
Bonus: Lab for-loop
Write a program to generate the series 1, 1, 2, 3, 5, 8, 13, ...
The series has a property that the third number is the sum of the first and second numbers. For example, 2=1+1, 3=1+2, and 5=2+3.
The series has a property that the third number is the sum of the first and second numbers. For example, 2=1+1, 3=1+2, and 5=2+3.
Quiz 10-12-2007
1. Let i, j be two integers. Write a program to exchange their values. How can you show your program is correct.
2. The identifier BufferedReader is normally abbreviated as BR in programming language C. However, Java programmers normally do not use abbreviations for identifiers. What are the advantages and disadvantages of not using abbreviations?
2. The identifier BufferedReader is normally abbreviated as BR in programming language C. However, Java programmers normally do not use abbreviations for identifiers. What are the advantages and disadvantages of not using abbreviations?
Lab: Tax Calculation
Study Display 3.1. Based on the income tax rate in Taiwan,
calculate the income tax of a person whose annual income is 1,000,000 or 2,000,000.
calculate the income tax of a person whose annual income is 1,000,000 or 2,000,000.
星期二, 10月 09, 2007
星期五, 10月 05, 2007
10-5-2007 點名未到
電子三乙 郭逸興
電子三乙 李文森
電子三丙 謝志揚
電子三丙 潘冠宇
電子三甲 鄭安舜
電子四乙 黃璽祐 (有請假單)
電子四乙 林士傑 (有請假單)
電子四甲 曾韋碩
醫工四甲 東峻平
電子三乙 李文森
電子三丙 謝志揚
電子三丙 潘冠宇
電子三甲 鄭安舜
電子四乙 黃璽祐 (有請假單)
電子四乙 林士傑 (有請假單)
電子四甲 曾韋碩
醫工四甲 東峻平
Lab: Keyborad Input
Rewrite Display 2.6 using BufferedReader.
You need to import the following packages in the first place.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
Change
Scanner keyboard= new Scanner(System.in);
into
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
String inputString = keyboard.readLine();
Note the Main method needs IOException handling as follows:
public static void main (String[] args) throws IOException
You need to import the following packages in the first place.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
Change
Scanner keyboard= new Scanner(System.in);
into
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
String inputString = keyboard.readLine();
Note the Main method needs IOException handling as follows:
public static void main (String[] args) throws IOException
Lab: Adding Links on Your Blog
1. Check into your blog homepage.
2. Enter "自訂"
3. Select "連結清單"
4. Write down "http://javaatcycu.blogspot.com/" and the title as "Java物件導向程式設計"
5. Also add your own favorite links.
2. Enter "自訂"
3. Select "連結清單"
4. Write down "http://javaatcycu.blogspot.com/" and the title as "Java物件導向程式設計"
5. Also add your own favorite links.
Programming Styles
Goal:
Make your code easy to read and easy to modify.
Spelling conventions
Self-documenting
Make your code easy to read and easy to modify.
Spelling conventions
- name the variables as the names suggest
- Start the name of classes with uppercase letters (such as String, FirstProgram) and start the names of variables, objects, and methods with lowercase letters.
- Word boundaries are indicated by an uppercase letter, as in numberOfPods
- Java spells things out in full. Use BufferedReader instead of BufReader, BuffReader, BufferedR or BR. With abbreviations, we often cannot recall how the identifier is abbreviated.
- "Just enough" is enough.
- When something is important and not obvious, it merits a comment.
- Example of unnecessary comment
Self-documenting
- the structure of the program is clear from the choice of identifier names and indenting pattern.
- The general rule of indenting is easy. When one structure is nested inside another structure, the inside structure is indented one more level.
- We prefer to use four spaces for each level of indenting. Indenting only two or three spaces is fine so long as you are consistent. One space is not enough to be clearly visible.
Oct-12-2007 Quiz of Chap. 1
Format: Open book, computer-based test
Running time: 30 min.
Scope: Chap. 1
Running time: 30 min.
Scope: Chap. 1
訂閱:
文章 (Atom)
星期五, 十月 26, 2007 1:10:00 下午
9326268 李致學
星期五, 十月 26, 2007 2:07:00 下午
電子三乙9426236林庭輝
星期五, 十月 26, 2007 2:08:00 下午