学习第一天-JAVA

第一题打印1到1000的奇数

public class OneToThousandOdd{

 public static void main(String[] args) {
            short num = 1000;
	short count = 0;
	for(;count <=1000; count++){
		if (count % 2 == 1)
			System.out.print(count+"
");
	}
}

}

第二题打印比输入数字小的所有能被3和5同时整除的数字

import java.util.Scanner;

public class Topic2{

public static void main(String[] args) {
	System.out.print("请输入:");
	Scanner scan = new Scanner(System.in);
	if (scan.hasNext()){
		int num = scan.nextInt();
		System.out.println("输入的数据为:"+ num);
		for(int i=0; i<=num; i++){
		if (i%3 == 0 && i%5==0)
			System.out.println("目标数值为:"+i+"
");
	}
	}


}

}

第三题判断输入所有整数的最大值

import java.util.Scanner;

public class Topic3{

public static void main(String[] args){
	int count = 0;
	int max = 0;
	while(true){
		System.out.printf("请输入第%d个要检测的数字:",count+1);
		Scanner num = new Scanner(System.in);
		if (count>=4)
			break;
		if(num.hasNextInt()){
			int result = num.nextInt();
			count++;
			if(result>max)
				max = result;
		} 
		else
			System.out.print("请输入整型数据");
	}
	System.out.println("最大数值为:"+ max);
}

}

HTML作业

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<a href="http://www.lingganjia.com/view/100131.htm" style="color:#5959B8;font-size:18px"><span style="color:#FF0000"><u>梵高</u></span>作品赏析 灵感家梵高</a>
		<p><span style="color:#FF0000">梵高</span>,荷兰后印象派画家。他是表现主义的先驱,并深深影响了二十世纪艺术,尤其是野兽派和德国表现主义
		,<span style="color:#FF0000" >梵高</span>的作品,如《星夜》、《向日葵》、《与有乌鸦的麦田等》,现...</p>
		<span style="color:#60B070;font-size:15px">www.lingganjia.com/vie...</span> 
		<a href="https://baike.baidu.com/item/%E7%99%BE%E5%BA%A6%E5%BF%AB%E7%85%A7/218241?fr=aladdin" style="color:#D5D5D5;font-size:18px">-百度快照</a><br />
		
		<a href="http://www.lingganjia.com/view/100131.htm" style="color:#5959B8;font-size:18px"><span style="color:#FF0000"><u>梵高</u></span>作品赏析 灵感家梵高</a>
		<p><span style="color:#FF0000">梵高</span>,荷兰后印象派画家。他是表现主义的先驱,并深深影响了二十世纪艺术,尤其是野兽派和德国表现主义
		,<span style="color:#FF0000" >梵高</span>的作品,如《星夜》、《向日葵》、《与有乌鸦的麦田等》,现...</p>
		<span style="color:#60B070;font-size:15px">www.lingganjia.com/vie...</span> 
		<a href="https://baike.baidu.com/item/%E7%99%BE%E5%BA%A6%E5%BF%AB%E7%85%A7/218241?fr=aladdin" style="color:#D5D5D5;font-size:18px">-百度快照</a><br />
		
		<a href="http://www.lingganjia.com/view/100131.htm" style="color:#5959B8;font-size:18px"><span style="color:#FF0000"><u>梵高</u></span>作品赏析 灵感家梵高</a>
		<p><span style="color:#FF0000">梵高</span>,荷兰后印象派画家。他是表现主义的先驱,并深深影响了二十世纪艺术,尤其是野兽派和德国表现主义
		,<span style="color:#FF0000" >梵高</span>的作品,如《星夜》、《向日葵》、《与有乌鸦的麦田等》,现...</p>
		<span style="color:#60B070;font-size:15px">www.lingganjia.com/vie...</span> 
		<a href="https://baike.baidu.com/item/%E7%99%BE%E5%BA%A6%E5%BF%AB%E7%85%A7/218241?fr=aladdin" style="color:#D5D5D5;font-size:18px">-百度快照</a>
		
	</body>
</html>

该注意的知识点

  • 从外部输入数据要import java.util.Scanner,在需要引入外部数据的位置Scanner input = new Scanner(System.in)
  • 判断输入数据类型input.hasNextInt()、input.hasNext()、input.hasNextDouble(),分别判断输入数据是不是整型、字符串型、双精度浮点型
  • 取出外部输入数据int num = input.nextInt()、num=input.next(),分别取出整型数据和字符串,注意目标的数据类型
  • System.out.print和System.out.println的用法大致相同,println输出带空格,print不带空格,printf用于格式输出,如:System.out.printf("这是第%d个数据",num)
  • if语句只能判断布尔类型,true、false小写tHTML中span、a、div等标签更改样式在style属性里面改,如修改p标签的颜色为
    <p style="color:#FF00000">修改标签为红色</p>
    修改多个属性时在style里面用;隔开要修改的属性如
    <span style="color:#5959B8;font-size:18px> 修改颜色和字体大小</span>
原文地址:https://www.cnblogs.com/zhz-8919/p/10596651.html