第九章作业~

第一题关于打印输出数字:

 

public class T09{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		System.out.println("请输入打印的行数:");
		int hang=input.nextInt();
		for (int i = 1; i <= hang; i++){
			for (int j = 1; j <= i; j++){
			System.out.print(j+" ");
	}
				System.out.println();
		}	
	}	
}
第二题卖鸡的题:(这题不太会。。有借鉴。。)
package t9;

import  java.uitl.Scanner;



public class T09
{
	public static void main(String[] args){
		
		
	for (int i = 0; i < 20; i++)
		{
	for (int j = 0; j < 33; j++)
			{
				int k=30-i-j;
				if((k/3+2*j+3*i)==50){
				System.out.print("公鸡"+i+"\t");
				System.out.print("母鸡"+j+"\t");
				System.out.print("雏鸡"+k+"\t");
					System.out.println();
				}
			}
		}
	}
}
第三题班级参赛成绩:
package cn.jbit.t9.test;

import java.util.Scanner;

public class T903 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		double[][] a = new double[3][4];
		double zongchengji = 0;
		int jige = 0;
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.println("请输入学员成绩:");
				double chengji = input.nextDouble();
			
				if (chengji>=85) {
					zongchengji = chengji+zongchengji;
					jige++;
					
				}
				
			}
		}
		System.out.println("平均成绩为:"+(int)(zongchengji/jige));
		
	}
 
第四题:ATM机
public class T9{

import java.util.Scanner;

public class Test11
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		for (int i = 0; i <=3; i++)
		{
			if(i==3){
				System.out.println("密码错误三次,系统退出");
				break;
			}
			System.out.println("请输入密码");
			String passworld=input.next();
			if(!passworld.equals("111111")){				
				System.out.println("密码错误");
				continue;
			}
			
			for (int j = 0; j < 10; j++)
			{
				System.out.println("请输入取款金额");
				int money=input.nextInt();
				if (money%100==0)
				{
					System.out.println("取款成功");
					break;
				}else{
					System.out.println("输入金额不合法,请重新输入");
				}
				
			}
			break;
		}
		
		
		
	}
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值