在慕课上面简单学习了一下java语言的用法
简单的用法总结记录一下。代码(学习输入,输出):
package hello;import java.util.Scanner;public class Hello { private static Scanner in; public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Hello!"); in = new Scanner(System.in);// 第一个hello_wolrd的Java程序// System.out.println("echo:"+in.nextLine());// int price = 0;// int amount=100;// System.out.print("请输入票面");// amount = in.nextInt();// System.out.print("请输入金额");// price = in.nextInt();// System.out.println(amount+"-"+price+"="+(amount-price));// 第二个Java简单程序 System.out.println(1.2-1.1); int foot; int inch; foot = in.nextInt(); inch = in.nextInt(); System.out.println("foot="+foot+" "+"inch="+inch); System.out.println((foot+inch/12.0)*0.3048); } }
代码(学习数据类型及用法细节):
import java.util.Scanner;public class Java_Second_Compare { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner (System.in);// 读入投币金额 System.out.print("请投币: "); int amount = in.nextInt(); System.out.println(amount>=10);// 打印车票 System.out.println("*************"); System.out.println("* Java城际铁路快线 *"); System.out.println("* 无指定座位票 *"); System.out.println("* 票价:10 *"); System.out.println("*************");// 计算并打印找零 System.out.println("找零:"+(amount-10)); int cnt=in.nextInt(); while(cnt>0) { System.out.println("当前的cnr值:"+cnt); cnt--; } int number=(int)(Math.random()*100+1); //计算机系统随机产生一个数字 System.out.println(number); int tmp=in.nextInt(); while(tmp!=number) { if(tmp
后续章节继续更新;