java课堂作业第九周

题目

代码

package ch09;

import java.util.Date;

public class Account { //Account类

    public static void main(String[] args) {

        Account account = new Account(1122, 20000);//初始化id和初始存款
        account.setAnnualInterestRate(4.5);//输入年利率
        account.withDraw(2500);//提取
        account.deposit(3000);//存储
        //打印余额,每月利息,以及该帐户创建的日期。
        System.out.println("Balance: "+account.getBalance()+"\n"
                +"Monthly Interest Rate: "+account.getMonthlyInterestRate()+"\n"
                +"Date Created: "+account.getDateCreated());
    }



    private int id = 0;
    private double balance = 0;
    private double annualInterestRate = 0;
    private Date dateCreated;

    public Account() {
        dateCreated = new Date();
    }

    public Account(int id, double balance) {
        this.id = id;
        this.balance = balance;
        dateCreated = new Date();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public double getMonthlyInterestRate() {
        double monthlyInterestRate = annualInterestRate / 12;
        return balance * monthlyInterestRate / 100;
    }

    public void withDraw(double money) {
        balance -= money;
    }

    public void deposit(double money) {
        balance += money;
    }

}

package ch09;
import java.util.Date;
import java.util.ArrayList;
public class b {
    public static void main(String[] args) {
        TestAcount ta = new TestAcount();
        ta.main(args);
    }
}
class TestAcount{
    public static void main(String[] args) {
        Acount a = new Acount();
        long time = System.currentTimeMillis();
        a.deposit('D', 30,time);//模拟存取款时的时间
        a.deposit('D', 40,time + 100000000);
        a.deposit('D', 50,time + 200000000);
        a.withDraw('W', 5,time + 400000000);
        a.withDraw('W', 4,time + 800000000);
        a.withDraw('W', 3,time + 1600000000);
        a.printJiLu();
        System.out.println("账户创建日期为:"+a.getDateCreated());
    }
}
class Acount{
    private String name;
    private int id;
    protected double balance;
    private double annualInterestRate;
    private Date dateCreated;
    private ArrayList jiaoyijilu = new ArrayList();
    Acount(){
        this("George",1122,1000,1.5);
    }
    Acount(String name,int id,double balance,double annualInterestRate){
        this.name = name;
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
        dateCreated = new Date();
    }
    public int getId(){
        return id;
    }
    public void setId(int newID){
        id = newID;
    }
    public double getBalance(){
        return balance;
    }
    public void setBalance(double newBalance){
        balance = newBalance;
    }
    public double getAnnualInterestRate(){
        return annualInterestRate;
    }
    public void setAnnualInterestRate(double newRate){
        annualInterestRate = newRate;
    }
    public String getDateCreated(){
        return dateCreated.toString();
    }
    public double getMonthlyInterestRate(){
        return annualInterestRate / 12.0;
    }
    public void withDraw(char type,double amount,long elapstime){
        Date date = new Date(elapstime);
        Transaction actions = new Transaction(type,amount,balance,date);
        jiaoyijilu.add(actions);
        balance = actions.getNewBalance();
    }
    public void deposit(char type,double amount,long elapstime){
        Date date = new Date(elapstime);
        Transaction actions = new Transaction(type,amount,balance,date);
        jiaoyijilu.add(actions);
        balance = actions.getNewBalance();
    }
    public void printJiLu(){
        System.out.println("名为:"+name+" ID: "+id+" 的账户交易记录如下:");
        for(int i = 0;i < jiaoyijilu.size();i++){
            System.out.println(jiaoyijilu.get(i).toString());
        }
    }
}
class Transaction extends Acount{
    private char type;
    private double amount;
    private double newBalance;
    private String description;
    public Transaction(char type,double amount,double balance,Date date){
        if(type == 'W'){
            newBalance = balance;
            newBalance -= amount;
            description = date.toString()+" 取款 "+amount+" 可用余额为:"+newBalance;
        }
        else if(type == 'D'){
            newBalance = balance;
            newBalance += amount;
            description = date.toString()+" 存款 "+amount+" 可用余额为:"+newBalance;
        }
    }
    public double getNewBalance(){
        return newBalance;
    }
    public String toString(){
        return description;
    }
}

package ch09;

import java.io.File;
import java.util.Scanner;

public class c {
    public static void main(String[] args) {
        try{
            Scanner scanner=new Scanner(new File("11.txt"));
            int [][] num = new int[20][20];
            for (int i = 0; i < 17; i++) {
            for (int j = 0; j < 20; j++) {
                int n=scanner.nextInt();
                //System.out.println(n);
                num[i][j]=n;
            }
            }
            //System.out.println(num);
            int max = 0;
            // 横向,从左到右
            for (int i = 0; i < 20; i++) {
                for (int j = 0; j < 17; j++) {

                    int multi = 1;
                    for (int k = 0; k < 4; k++) {
                        multi *= num[i][j + k];
                    }
                    max = multi > max ? multi : max;
                }
            }
            // 竖向,从上到下
            for (int i = 0; i < 17; i++) {
                for (int j = 0; j < 20; j++) {
                    int multi = 1;
                    for (int k = 0; k < 4; k++) {
                        multi *= num[i + k][j];
                    }
                    max = multi > max ? multi : max;
                }
            }
            // 右对角线,从左下到右上
            for (int i = 3; i < 20; i++) {
                for (int j = 0; j < 17; j++) {
                    int multi = 1;
                    for (int k = 0; k < 4; k++) {
                        multi *= num[i - k][j + k];
                    }
                    max = multi > max ? multi : max;
                }
            }
            // 左对角线,从左上到右下
            for (int i = 0; i < 17; i++) {
                for (int j = 0; j < 17; j++) {
                    int multi = 1;
                    for (int k = 0; k < 4; k++) {
                        multi *= num[i + k][j + k];
                    }
                    max = multi > max ? multi : max;
                }
            }
            // 输出最大值
            System.out.println(max);
        }
        catch (Exception e){
            e.printStackTrace();
        }

    }
}

 

下载前可以先看下教程 https://pan.quark.cn/s/16a53f4bd595 小天才电话手表刷机教程 — 基础篇 我们将为您简单的介绍小天才电话手表新机型的简单刷机以及玩法,如adb工具的使用,magisk的刷入等等。 我们会确保您看完此教程后能够对Android系统有一个最基本的认识,以及能够成功通过magisk root您的手表,并安装您需要的第三方软件。 ADB Android Debug Bridge,简称,在android developer的adb文档中是这么描述它的: 是一种多功能命令行工具,可让您与设备进行通信。 该命令有助于各种设备操作,例如安装和调试应用程序。 提供对 Unix shell 的访问,您可以使用它在设备上运行各种命令。 它是一个客户端-服务器程序。 这听起来有些难以理解,因为您也没有必要去理解它,如果您对本文中的任何关键名词产生疑惑或兴趣,您都可以在搜索引擎中去搜索它,当然,我们会对其进行简单的解释:是一款在命令行中运行的,用于对Android设备进行调试的工具,并拥有比一般用户以及程序更高的权限,所以,我们可以使用它对Android设备进行最基本的调试操作。 而在小天才电话手表上启用它,您只需要这么做: - 打开拨号盘; - 输入; - 点按打开adb调试选项。 其次是电脑上的Android SDK Platform-Tools的安装,此工具是 Android SDK 的组件。 它包括与 Android 平台交互的工具,主要由和构成,如果您接触过Android开发,必然会使用到它,因为它包含在Android Studio等IDE中,当然,您可以独立下载,在下方选择对应的版本即可: - Download SDK Platform...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值