当前位置 : 主页 > 编程语言 > java >

java常用代码段

来源:互联网 收集:自由互联 发布时间:2021-06-28
charge.java package hello;import java.util.Scanner;public class charge {public static void main(String[] args) {// TODO Auto-generated method stubSystem.out.println("您好");Scanner in = new Scanner(System.in);int price = 0;int amount = 10
charge.java
package hello;

import java.util.Scanner;

public class charge {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("您好");
		Scanner in = new Scanner(System.in);
		int price = 0;
		int amount = 1000;//final int means const
		System.out.print("请输入总额:");
		amount=in.nextInt();
		System.out.print("请输入金额:");
		price=in.nextInt();
		System.out.println("找零:"+amount+"-"+ price+"="+ (amount-price));// ""+a.b
	}

}
输入声明?
Scanner in = new Scanner(System.in);
上一篇:list去重
下一篇:用java进行数组排序
网友评论