java基础11节-练习

package hello;
import java.util.Scanner;
public class hello{
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	System.out.println("请输入一个星期数:");
	int week = sc.nextInt();
	
	if (week<1 || week>7) {
		System.out.println("您输入有误");
	}
		else if (week==1) {
			System.out.println("跑步");
		}else if (week==2) {
			System.out.println("游泳");
		}else if (week==3) {
			System.out.println("慢走");
		}else if (week==4) {
			System.out.println("动感单车");
		}else if (week==5) {
			System.out.println("拳击");
		}else if (week==6) {
			System.out.println("爬山");
		}else if (week==7) {
			System.out.println("好好吃一顿");
		}
	}
}

package hello;

import java.util.Scanner;

public class hello{
	public static void main(String[] args) {
		
	Scanner sc = new Scanner(System.in);
	System.out.println("请输入一个星期数:");
	int week = sc.nextInt();
	switch (week) {
	case 1:
		System.out.println("跑步");
		break;
	case 2:
		System.out.println("爬山");
		break;
	case 3:
		System.out.println("慢跑");
		break;
	case 4:
		System.out.println("休息");
		break;
	case 5:
		System.out.println("游泳");
		break;
	case 6:
		System.out.println("游戏");
		break;
	case 7:
		System.out.println("好好吃一顿");
		break;
	default:
		System.out.println("你输入有误");
		
	}
	}
}
package hello;

import java.util.Scanner;

public class hello{
	public static void main(String[] args) {
	for (int x = 1;x<=100;x++) {
		if (x%10==7 || x/10%10==7 || x%7==0) {
			System.out.println(x); 
		}
	}
	}
}
package hello;

import java.util.Scanner;

public class hello{
	public static void main(String[] args) {
		int[] arr = new int[20];
		arr[0] = 1;
		arr[1] = 1;
		
		for (int x = 2;x<arr.length;x++) {
			arr[x] = arr[x-2] + arr[x-1];
		}
		System.out.println(arr[19]);
	}
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值