提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
提示:这里可以添加本文要记录的大概内容:
例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。
提示:以下是本篇文章正文内容,下面案例可供参考
一、JAVA汽车销量练习
二、使用步骤
1.引入库
代码如下(示例):
package car;
public class Car {
//品牌 型号 颜色 座位数 单价 月销量等属性
private String brand;
private String type;
private String color;
private int seat;
private int price;
private int quantity;
public Car() {
super();
// TODO Auto-generated constructor stub
}
public Car(String brand, String type, String color, int seat, int price, int quantity) {
super();
this.brand = brand;
this.type = type;
this.color = color;
this.seat = seat;
this.price = price;
this.quantity = quantity;
}
2.读入数据
代码如下(示例):
package car;
public class TestCar {
public static void main(String[] args) {
// TODO Auto-generated method stub
int total = 0;
int amount=0;
Car[] cars = new Car[3];
cars[0] = new Car("问界", "M7", "黑色", 5, 379800, 20);
cars[1] = new Car("智界", "S7", "白色", 5, 349800, 10);
cars[2] = new Car("极狐", "T5", "灰色", 5, 329800, 15);
System.out.println("上月销售情况表");
System.out.println("品牌\t型号\t颜色\t座位数\t单价\t月销量\t月销金额");
System.out.println("-----------------------------------------------------------");
for (int i = 0; i < cars.length; i++) {
System.out.println(cars[i].getBrand() + "\t" +cars[i].getType() +"\t" +cars[i].getColor()+
"\t" +cars[i].getSeat() + "\t" +cars[i].getPrice() +"\t" +cars[i].getQuantity() +
"\t" +cars[i].cal());
total += cars[i].getQuantity();
amount += cars[i].cal();
}
System.out.println("-----------------------------------------------------------");
//:45,:16041000
System.out.println("上月汽车总销量:"+total+"总销售金额:"+amount);
}
}
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。