Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 1. 宣告兩 int 變數, 印出其和、積、差、商
- 2. 宣告兩 double 變數, 印出其和、積、差、商
- */
- public class HW2 {
- public static void main(String[] args) {
- //宣告int 並指定值
- int a = 300;
- int b = 200;
- System.out.println(int a + int b); // 和
- System.out.println(int a * int b); // 積
- System.out.println(int a - int b); // 差
- System.out.println(int a / int b); // 商
- //宣告double 並指定值
- double c = 30.5;
- double d = 20.5;
- System.out.println(double c + double d); // 和
- System.out.println(double c * double d); // 積
- System.out.println(double c - double d); // 差
- System.out.println(double c / double d); // 商
- }
- }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement