package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("你好");
Scanner in = new Scanner(System.in);
// System.out.println("100-23="+(100-in.nextInt()));
final int amount = 100;
int price = 0;
System.out.println(price);
price = in.nextInt();
System.out.println(amount+"-"+price+"="+(amount-price));
}
}
--------------------------------------------
final int amount :定義常量,是值不以值的面目出現。
package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("你好");
Scanner in = new Scanner(System.in);
// System.out.println("100-23="+(100-in.nextInt()));
int amount = 100;
int price = 0;
System.out.print("請輸入票面:");
amount = in.nextInt();
System.out.print("請輸入金額:");
price = in.nextInt();
System.out.println(amount+"-"+price+"="+(amount-price));
}
}
----------------------------------------------------------------------
System.out.print("請輸入票面:"); :加入一些輸出,界面更友好。