This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework.week7; | |
public class Employee { | |
private String firstName; | |
private String lastName; | |
public Employee(String firstName, String lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.(戶頭) | |
實作一戶頭類別Account,內含私有餘額balance,型別實數, | |
對外提供如下公開方法: | |
public Account(double initialBalance) //建構子,含初始餘額 | |
public void credit(double amount) // 存款,含存款金額 | |
public double getBalance() // 讀出餘額,回傳餘額 | |
測試時,可用建構子建立一個戶頭,初始餘額為50,先印餘額看對不對, | |
再存入25,印餘額看對不對. | |
註: 建構子若遇初始餘額<0,可一律設定為0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student{ | |
// 靜態 - | |
int score = 0; | |
// 動態 - | |
public void play(int hours){ | |
score = score - hours; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.(數列反印) 亂數產生10個介於2~2000的偶數,依序存到陣列內,再反印之, | |
輸出範例 | |
原始數列: 250 1400 890 126 1844 734 182 1922 36 976 | |
反印數列: 976 36 1922 182 734 1844 126 890 1400 250 | |
2.(數列和) 亂數產生10個整數,值介於1-99之間,求10個整數和. | |
3.請寫一個 Method, 接收最大亂數值、最小亂數值產生一個落在範圍裡的亂數,並印出 | |
public void printRandom(int max, int min){ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.給予 int x,請計算 y 值,其公式如下: | |
y = 3 * x^2 若 x < -1 | |
y = x^3 + 3 * x - 3 若 -1 <= x <= 1 | |
y = 2 * x + 3 若 x > 1 | |
2.給予三角形三邊長(int)a,b,c,請判斷是直角,銳角,鈍角,或非三角形. | |
(註:假設邊長排序結果,a <= b <= c,則 | |
直角(right triangle): c*c = a*a + b*b | |
鈍角(obtuse triangle): c*c > a*a + b*b | |
銳角(sharp triangle): c*c < a*a + b*b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" | |
version="3.1"> | |
<servlet> | |
<servlet-name>SimpleServlet</servlet-name> | |
<servlet-class>week3.SimpleServlet</servlet-class> | |
</servlet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
public class OCR { | |
public static void main(String[] args) | |
{ | |
String first = "1ba"; | |
String second = "a1a"; | |
boolean res = Ocr(first, second); | |
System.out.println(res); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
public class OCR { | |
public static void main(String[] args) | |
{ | |
String first = "ba6"; | |
String second = "1Ad"; | |
boolean res = Ocr(first, second); | |
System.out.println(countingWordsLength(first)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Excperf { | |
public void method1(int size){ | |
int [] ia = new int[size]; | |
try{ | |
for (int i = 0;i<size ; i++){ | |
ia[i] = i; | |
} | |
} catch (Exception e){ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void demoException() throws Exception{ | |
try{ | |
throw new ("Exception A"); | |
} catch (Exception e){ | |
throw new NestableException("Exception B", e); | |
} | |
} |