package hello;
import java.util.Scanner;
public class Hello {
private static Scanner in;
public static void main(String[] args) {
in = new Scanner(System.in);
int price=0;
int amount=0;
System.out.print("请输入票面");
amount=in.nextInt();
System.out.print("请输入金额");
price =in.nextInt();
System.out.println(amount+"-"+price+"="+(amount-price));
}
}
JAVA的输入输出语句:
System.out.println(“Hello JAVA" );
注意:
①System首字母大写,
②Println和print区别:println输出后换行;print只输出不换行(建议用Println)
Scanner in =new Scanner(System.in);
System.out.println(in.nextLine());
①运算符+可以用来将两个字符串加起来
适当增加一些()也可以进行算术运算