# 答答租车系统（面向对象综合练习）

Problem Description

（人） （吨） （元/天）
1 A 5 800
2 B 5 400
3 C 5 800
4 D 51 1300
5 E 55 1500
6 F 5 0.45 500
7 G 5 2.0 450
8 H 3 200
9 I 25 1500
10 J 35 2000

Input

Output

0 0.00 0（含义同上）

Sample Input
1
2
1 1
2 2
Sample Output
15 0.00 1600

package pp;

import java.util.*;

class Car {
int name, money, passenger;
double weight;

public Car(int name, int money, double weight,  int passenger) {//顺序要对
super();
this.name = name;
this.money = money;
this.passenger = passenger;
this.weight = weight;
}

}

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Car [] c = {
new Car(0, 5, 0, 800),
new Car(1, 5, 0, 400),
new Car(2, 5, 0, 800),
new Car(3, 51, 0, 1300),
new Car(4, 55, 0, 1500),
new Car(5, 5, 0.45, 500),
new Car(6, 5, 2, 450),
new Car(7, 0, 3, 200),
new Car(8, 0, 25, 1500),
new Car(9, 0, 35, 2000)
};
int peoplesum = 0;
int moneysum = 0;
double weightsum = 0;
int order = sc.nextInt();
if(order == 1) {//租车
int num = sc.nextInt();//组几辆
for(int i = 0; i < num; i++) {
int j = sc.nextInt() - 1;//编号
int day = sc.nextInt();//天数
moneysum += c[j].money * day;
peoplesum += c[j].passenger * day;
weightsum += c[j].weight * day;
}
System.out.println(moneysum + " " + String.format("%.2f", weightsum) + " " + peoplesum);
}
else {
System.out.println(moneysum + " " + String.format("%.2f", weightsum) + " " + peoplesum);
}
sc.close();
}
}


• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120