day01

九九乘法表

package nlday01;

public class nnmulti {
	public static void main(String[] args) {
       for(int i=1;i<10;i++){
         for(int j=1;j<i+1;j++){
        	System.out.print(i+"*"+j+"="+i*j+"\t"); 
         }
         System.out.println();
      }
   }
}

运行结果如下代码里有很多值得修改的地方我做过两次这题,但都只是看一眼,都被整体换行难住了, System.out.println();以及两个for的搭配。(如果有大佬看见我的代码,不要见笑~)

根据月份判断季节

package nlday01;

public class season {

	public static void main(String[] args) {
		boolean flag = true;
		while(flag){
			System.out.println("Please input your month:(press 0 to stop p)");
			Scanner scan = new Scanner(System.in);	
			int month = scan.nextInt();
		switch(month){
		case 12: 
		case 1: 
		case 2: System.out.println("winter");break;
		case 3: 
		case 4: 
		case 5: System.out.println("spring");break;
		case 6: 
		case 7: 
		case 8: System.out.println("summer");break;
		case 9: 
		case 10: 
		case 11: System.out.println("fall");break;
		case 0:flag = false;break;
		default: System.out.println("error");break;
		}
		}
	}
	}

这个代码,我一开始竟然很蠢的写了12行System.out.println();后来才发现有些看可以不用加break。。。还有,文中有波浪线或者错误的,我当时也不知道要添加头文件。
运行结果如下:小学生代码~

Java中的数组

在这里插入图片描述
老师主要讲了数组的定义

类和对象

package nlday01;

public class Person {
   private String name;//define les shuxing
   private int age;
   private char sex;
 //定义类的方法
   public void eat(){
	   System.out.println("feed my belly");
}
   public void sleep(String where){
	   System.out.println("i am at" + where + "sleep");
} 
   public int study(){
	   int count = (int)(Math.random()*10);
	   System.out.println("i love study" + count + "kinds subjects");
	   return count;
   }
  public static void main(String[] args){
	   Person person = new Person();
	   person.name = "HuiZhen.Yu";
	   person.age = 20;
	   person.sex = '女';
	   person.eat();
	   person.sleep("yifulou");
	   person.study();
   }
}

运行结果如下:在这里插入图片描述
这里老师开车很快,用苍老师和石老师给我们当例子,哈哈哈。

五次机会猜数

老师要来关门了,我先回宿舍,明早来补充这个代码。顺便明天把day02和day03的补上,尽量明天把day04的也加上。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值