1. 試寫一個程式,使用 if 條件運算,採互動方式讓使用者輸入任一數字,然後告知使用者
是奇數或是偶數
請輸入一個數值:
→ 11
您輸入的是:奇數
2. 請撰寫 if 條件運算的程式,採互動方式輸入學生的成績,當成績在 90~100 分之間時,
輸出為 A,成績在 80~89 分時為 B,範圍在 70~79 分為 C,落在 60~69 為 D,未滿 60
為 E。
請輸入成績:
→ 95
您的成績等第為:A
3. 承上,改用 switch-case 方式來撰寫程式。
4. 試寫一個程式,比較兩個使用者輸入的數字大小,並依使用者選擇來輸出四則運算的結
果。
請輸入數值1:
→ 33
請輸入數值2:
→ 22
數值1:33比數值2:22來得大
請選擇(1)加(2)減(3)乘(4)除
→ 3
33 * 22 = 726
5. 請撰寫程式,算出三角形、矩形以及梯形的面積。當使用者選擇三角形時,必須要求使
用者輸入底與高。使用者選擇矩形時,要求輸入長與寬。選到梯形時,要求輸入上底、下底
及高。
請選擇(1)三角形(2)矩形(3)梯形
→ 1
請輸入(下)底長
→ 10
請輸入高
→ 6
三角形面積為:30.02
6. 請撰寫程式,讓使用者可以輸入密碼,密碼錯誤時,需輸出錯誤訊息來告知使用者,反
之正確時,輸出正確訊息來告知使用者。密碼為只由整數數字組成,範圍 1000~9999 之間,
由程式設計者自行決定。
請輸入密碼(1000~9999):
→ 1001
密碼錯誤
7. 一家電信公司的計費方式:每個月打 799 分鐘以下,每分鐘 0.9 元,800 分鐘~1499
分鐘時,所有電話費以 9 折計價,若超過 1500 分鐘,則通話費以 79 折計算,並於畫面上
顯示其通話費。
請輸入通話分鐘數:
→ 999
999 分鐘的通話費用為:809.19
8. 已知男生標準體重=(身高-80)*0.7,女生標準體重=(身高-70)*0.6,試寫一程式可
計算男女生的標準體重。(提示:讓使用者先選擇性別,再決定程式套用的公式)
請輸入身高:
→ 180
請輸入性別(1)男生(2)女生:
→ 1
180 公分的男生理想體重為 70.0公斤
9. 試寫一程式,讓使用者可輸入籃球員的平均得分、籃板、助攻、抄截及失誤等數值,並
依「(得分*1+助攻*2+籃板*2+抄截*2)-(失誤*2)」的公式來取得此籃球員 MVP 數值。
大於 45 分以上則為 A 級球員。
35~44 分為 B 級球員。
25~34 之間為板凳級球員。
低於 25 分為萬年級板凳球員。
請輸入平均得分:
→ 10
請輸入籃板數:
→ 3
請輸入助攻數:
→ 4
請輸入抄截數:
→ 3
請輸入失誤數:
→ 3
萬年板凳球員3
10. 試寫一個程式,讓使用者可輸入整月的工時數及每月的固定時薪,並將其所應獲得的工
資顯示在螢幕上。工資計算方式如下:
方式 1:60 hr(含)以下的薪水部分,以固定時薪計算。
方式 2:61~120 hr 之間的薪水部分,以固定時薪的 1.33 倍計算
方式 3:121 hr 以上的薪水部分,以固定時薪的 1.66 倍計算
請輸入一個月的工時:
→ 66
請輸入時薪:
→ 300
您的薪水為:20394.0
2014年10月17日 星期五
2014年10月13日 星期一
java-i++和++i的差別
i++和++i都是i=i+1的意思
但有什麼差別
讓我們看一下
static void test2(){ int a = 5,b; b=a++; System.out.println("a=5 b=a++ "+b); //後置運算,先做b=a,再做a++ System.out.println("a="+a); System.out.println("b="+b); a=5; b=++a; System.out.println("a=5 b=++a "+a); //前置運算,先做a++,再做b=a System.out.println("a="+a); System.out.println("b="+b); } }
執行結果
a=5 b=a++ 5(後做a=a+1)
a=6
b=5
a=5 b=++a 6 (先做a=a+1)
a=6
b=6
但有什麼差別
讓我們看一下
static void test2(){ int a = 5,b; b=a++; System.out.println("a=5 b=a++ "+b); //後置運算,先做b=a,再做a++ System.out.println("a="+a); System.out.println("b="+b); a=5; b=++a; System.out.println("a=5 b=++a "+a); //前置運算,先做a++,再做b=a System.out.println("a="+a); System.out.println("b="+b); } }
執行結果
a=5 b=a++ 5(後做a=a+1)
a=6
b=5
a=5 b=++a 6 (先做a=a+1)
a=6
b=6
Java-練習題
1. 請撰寫一個程式,其中包含一個代表正方形邊長的變數,設定邊長後計算並顯示出正方形
的面積
正方形面積為:100
2. 請撰寫一個程式,宣告兩個浮點數的變數,設定變數值後,計算並顯示出這兩個變數的和
與積
兩數和為:3.9000000000000004
兩數積為:3.3800000000000003
3. 請撰寫一個程式,宣告一個變數,設定其變數值,計算並顯示這個變數值的平方值與立方
值
平方值為:25
立方值為:125
4. 請撰寫一個程式,將標準萬國碼中字碼為97 到99 之間的字元顯示在螢幕上
字碼:97 的字元為 a
字碼:98 的字元為 b
字碼:99 的字元為 c
5. 請撰寫一個程式,在螢幕上顯示如下的訊息(必須顯示出反斜線):
\這是程式練習的習題\
6. 請撰寫一個程式,將x 這個字元的對應標準萬國碼顯示出來
字元:x 的字碼為:120
7. 請撰寫一個程式,宣告兩個變數,設定變數值後,計算並顯示這兩個變數的和的平方值
和的平方值為:144
8. 請撰寫一個程式,在螢幕上顯示以下訊息:
我正在學習 "Java 程式語言"
9. 請撰寫一個程式,顯示單引號(')的標準萬國碼
字元:'的字碼為:39
的面積
正方形面積為:100
2. 請撰寫一個程式,宣告兩個浮點數的變數,設定變數值後,計算並顯示出這兩個變數的和
與積
兩數和為:3.9000000000000004
兩數積為:3.3800000000000003
3. 請撰寫一個程式,宣告一個變數,設定其變數值,計算並顯示這個變數值的平方值與立方
值
平方值為:25
立方值為:125
4. 請撰寫一個程式,將標準萬國碼中字碼為97 到99 之間的字元顯示在螢幕上
字碼:97 的字元為 a
字碼:98 的字元為 b
字碼:99 的字元為 c
5. 請撰寫一個程式,在螢幕上顯示如下的訊息(必須顯示出反斜線):
\這是程式練習的習題\
6. 請撰寫一個程式,將x 這個字元的對應標準萬國碼顯示出來
字元:x 的字碼為:120
7. 請撰寫一個程式,宣告兩個變數,設定變數值後,計算並顯示這兩個變數的和的平方值
和的平方值為:144
8. 請撰寫一個程式,在螢幕上顯示以下訊息:
我正在學習 "Java 程式語言"
9. 請撰寫一個程式,顯示單引號(')的標準萬國碼
字元:'的字碼為:39
CH03 程式練習解答.txt 1. 請撰寫一個程式,其中包含一個代表正方形邊長的變數,設定邊長後計算並顯示出正方形的面積 public class Pgm_03_01 { public static void main(String[] argv) { int side = 10; // 邊長 int area = side * side; // 面積 System.out.println("正方形面積為:" + area); } } 2. 請撰寫一個程式,宣告兩個浮點數的變數,設定變數值後(請自行指定),計算並顯示出這兩個變數的和與積 public class Pgm_03_02 { public static void main(String[] argv) { double f1, f2; f1 = 1.3; f2 = 2.6; double sum = f1 + f2; // 計算兩數和 double product = f1 * f2; // 計算兩數積 System.out.println("兩數和為:" + sum); System.out.println("兩數積為:" + product); } } 3. 請撰寫一個程式,宣告一個變數,設定其變數值,計算並顯示這個變數值的平方值與立方值 public class Pgm_03_03 { public static void main(String[] argv) { int i; i = 5; int square = i * i; // 計算平方值 int cubic = i * i * i; // 計算立方值 System.out.println("平方值為:" + square); System.out.println("立方值為:" + cubic); } } 4. 請撰寫一個程式,將標準萬國碼中字碼為97到99之間的字元顯示在螢幕上 public class Pgm0401 { public static void main(String[] argv) { char c; int i; c = '\u0061'; // 16進位61為97 i = c; System.out.println("字碼:" + i + "的字元為 " + c); c = '\u0062'; // 16進位62為98 i = c; System.out.println("字碼:" + i + "的字元為 " + c); c = '\u0063'; // 16進位63為99 i = c; System.out.println("字碼:" + i + "的字元為 " + c); } } 5. 請撰寫一個程式,在螢幕上顯示如下的訊息(必須顯示出反斜線): public class Pgm_03_05 { public static void main(String[] argv) { System.out.println("\\這是程式練習的習題\\"); } } 6. 請撰寫一個程式,將x 這個字元的對應標準萬國碼顯示出來 public class Pgm_03_06 { public static void main(String[] argv) { char c = 'x'; int i = c; System.out.println("字元:" + c + "的字碼為:" + i); } } 7. 請撰寫一個程式,宣告兩個變數,設定變數值後,計算並顯示這兩個變數的和的平方值 public class Pgm_03_07 { public static void main(String[] argv) { int i, j; i = 5; j = 7; int sum = i + j; // 計算和 int square = sum * sum; // 計算和的平方值 System.out.println("和的平方值為:" + square); } } 8. 請撰寫一個程式,在螢幕上顯示以下訊息: public class Pgm_03_08 { public static void main(String[] argv) { System.out.println("我正在學習 \"Java程式語言\""); } } 9. 請撰寫一個程式,顯示單引號(')的標準萬國碼 public class Pgm_03_09 { public static void main(String[] argv) { char c = '\''; int i = c; System.out.println("字元:" + c + "的字碼為:" + i); } }
Java-圓周長和圓面積的計算
import java.util.Scanner; //載入互動輸入
public class pi
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
double r;
Scanner scanner = new Scanner(System.in);
System.out.print("請輸入圓的半徑長度:");
r = scanner.nextInt();
scanner.close();
final double pi = 3.141592654; //final 將常數指定常變數
System.out.println("直徑:"+(2*r));
System.out.println("圓周長:"+(2*r*pi));
System.out.println("圓面積:"+(r*r*pi));
}
}
public class pi
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
double r;
Scanner scanner = new Scanner(System.in);
System.out.print("請輸入圓的半徑長度:");
r = scanner.nextInt();
scanner.close();
final double pi = 3.141592654; //final 將常數指定常變數
System.out.println("直徑:"+(2*r));
System.out.println("圓周長:"+(2*r*pi));
System.out.println("圓面積:"+(r*r*pi));
}
}
2014年10月8日 星期三
Java- 簡單的運算
//載入Scanner
import java.util.Scanner;
public class i20
{
/**
* @param args
*/
public static void main(String[] args)
{
float i, j;
float k;
Scanner scanner = new Scanner(System.in);
System.out.print("請輸入 i 的整數值:");
i = scanner.nextInt();
System.out.print("請輸入 j 的整數值:");
j = scanner.nextInt();
scanner.close();
System.out.println("變數i="+i);
System.out.println("變數j="+j);
k=i+j;
System.out.println("變數i+j="+k);
k=i-j;
System.out.println("變數i-j="+k);
k=i*j;
System.out.println("變數i*j="+k);
k=i/j;
System.out.println("變數i/j="+k);
}
}
import java.util.Scanner;
public class i20
{
/**
* @param args
*/
public static void main(String[] args)
{
float i, j;
float k;
Scanner scanner = new Scanner(System.in);
System.out.print("請輸入 i 的整數值:");
i = scanner.nextInt();
System.out.print("請輸入 j 的整數值:");
j = scanner.nextInt();
scanner.close();
System.out.println("變數i="+i);
System.out.println("變數j="+j);
k=i+j;
System.out.println("變數i+j="+k);
k=i-j;
System.out.println("變數i-j="+k);
k=i*j;
System.out.println("變數i*j="+k);
k=i/j;
System.out.println("變數i/j="+k);
}
}
程式開發-變更eclipse工作視窗色彩
Color Theme http://eclipse-color-theme.github.com/update (下載安裝之後,會要求重新啟動 Eclipse,重啟之後,接著建議先套用一個樣式, 例如 Preference/General/Appearance/Color Theme/Sunburst ) MoonRise UI https://raw.github.com/guari/eclipse-ui-theme/master/com.github.eclipseuitheme.themes.updatesite (下載安裝之後,會要求重新啟動 Eclipse,重啟之後,接著從 Preference/General/Appearance/右方的Theme/選擇 MoonRise(standalone)
程式開發-建置android與Java程式的開發環境
- 下載JDK
http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html - 下載eclipse
https://www.eclipse.org/downloads/ - 下載eclipse(用於android開發)
http://developer.android.com/sdk/index.html - 全部都解壓縮到個人資料夾(為避免影響其它班的使用者)
- 檢查系統環境變數(為避免影響其它班的使用者)
需移除"C:\Program Files\Java\jdk*****\bin" - 新增環境變數使用者部份,變數值為"C:\Program Files\Java\jdk*****\bin"
- 建立第一個程式,檔名為FirstJava.java
public class FirstJava {public statie void main (String [] argv) {System.out.println ("This is my first Java App.");}}
- 編輯程式在cmd 下執行javac FirstJava.java
- 執行程式在cmd 下執行java FirstJava
2014年10月6日 星期一
同網域有多台dc
同網域有多台dc
如何解決Infrastructure (基礎結構)與gc衝突的問題
答:
①若只有一台dc是gc,請將此dc的infrastructure角色移到其它dc
或
②讓所有的DC階擔任GC則infrastructure角色不必轉移
如何解決Infrastructure (基礎結構)與gc衝突的問題
答:
①若只有一台dc是gc,請將此dc的infrastructure角色移到其它dc
或
②讓所有的DC階擔任GC則infrastructure角色不必轉移
2014年9月29日 星期一
安裝AD Schema
http://technet.microsoft.com/en-us/library/cc732110.aspx
Install the Active Directory Schema Snap-In
19 out of 23 rated this helpful - Rate this topic
Updated: October 22, 2010
Applies To: Windows Server 2008, Windows Server 2008 R2, Windows Server 2012
You can use this procedure to first register the dynamic-link library (DLL) that is required for the Active Directory Schema snap-in. You can then add the snap-in to Microsoft Management Console (MMC).
Membership in Domain Admins , or equivalent, is the minimum required to complete this procedure. Review details about using the appropriate accounts and group memberships at http://go.microsoft.com/fwlink/?LinkId=83477.
To install the Active Directory Schema snap-in
- To open an elevated command prompt, click Start , type command prompt , and then right-click Command Prompt when it appears in the Start menu. Next, click Run as administrator , and then click OK .To open an elevated command prompt in Windows Server 2012, click Start , type cmd , right click cmd and then click Run as administrator .
- Type the following command, and then press ENTER:
regsvr32 schmmgmt.dll
Tip
Although the regsvr32 command shows that it is a 32-bit based command, it does run properly in the 64-bit versions of the supported operating systems (see Applies To near the start of this topic). The module ‘schmmgmt.dll’ was loaded but the call to DllRegisterServer failed with error code 0x80040201.
- Click Start , click Run , type mmc , and then click OK .
- On the File menu, click Add/Remove Snap-in .
- Under Available snap-ins , click Active Directory Schema , click Add , and then click OK .
- To save this console, on the File menu, click Save .
- In the Save As dialog box, do one of the following:
- To place the snap-in in the Administrative Tools folder, in File name , type a name for the snap-in, and then click Save .
- To save the snap-in to a location other than the Administrative Tools folder, in Save in , navigate to a location for the snap-in. In File name , type a name for the snap-in, and then click Save .
- To place the snap-in in the Administrative Tools folder, in File name , type a name for the snap-in, and then click Save .
2014年9月26日 星期五
To use Ldp to search the domain for deleted objects (tombstones)
To use Ldp to search the domain for deleted objects (tombstones)
- On the power shell , and then type ldp .
- Connect and bind to a domain controller in the domain whose tombstones you want to retrieve.
- To connect, on the Connection menu, click Connect , and then type a server name and a port number.(連其它伺服器)
- To bind, on the Connection menu, click Bind , and then type an account name, password, and domain if you want to connect to a domain other than the domain to which you are currently logged on.(本機)
- On the Browse menu, click Search .
- In the Search dialog box, for Base DN , type the distinguished name of the domain whose tombstones you want to retrieve.
- In the Filter box, use the filter (isDeleted=*) .
- Under Scope , click Subtree .
- Click Options .
- In the Search Options dialog box, under Search Call Type , click Extended .
- Click Controls . Then in the Object Identifier box, type the following: 1.2.840.113556.1.4.417
- Under Control Type , click Server .
- To add the control to the Active Controls list, click Check in . Then click OK .
- In the Search Options dialog box, click OK .
- In the Search dialog box, click Run .
2014年9月24日 星期三
Server Backup - Recover
如果有進行排程,請在此選還原點
這是要還原檔案或資料夾,
(如果要選原整個磁區,選Volumes)
電腦還原點
系統發現有一個資料夾有變更
1.還原到原來的地方
2.如果有相同的檔案,選擇保留二個版本(當然也可以選覆寫,只是後來變更的檔案就會被還原)
按Recover 確認還原
還原成功,關閉還原精靈即可。
0924- server設定
訂閱:
文章 (Atom)