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

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

Time Limit: 1000 ms Memory Limit: 65536 KiB

#### 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

0 0.00 0（含义同上）

#### Sample Input

1
2
1 1
2 2

#### Sample Output

15 0.00 1600

import java.util.*;
class Car{
int people, price;
double thing;
public void start(int n) {
switch(n) {
case 1:people = 5; thing = 0; price = 800;break;
case 2:people = 5; thing = 0; price = 400;break;
case 3:people = 5; thing = 0; price = 800;break;
case 4:people = 51; thing = 0; price = 1300;break;
case 5:people = 55; thing = 0; price = 1500;break;
case 6:people = 5; thing = 0.45; price = 500;break;
case 7:people = 5; thing = 2.0; price = 450;break;
case 8:people = 0; thing = 3; price = 200;break;
case 9:people = 0; thing = 25; price = 1500;break;
case 10:people = 0; thing = 35; price = 2000;break;
}
}
public void end(int m) {
people *= m;
thing *= m;
price *= m;
}
public void put() {
System.out.printf("%d %.2f %d\n", people, thing, price);
}
}
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
while(t != 0) {
Car c = new Car();
int x = cin.nextInt();
while(x != 0) {
int n = cin.nextInt();
int m = cin.nextInt();
Car a = new Car();
a.start(n);
a.end(m);
c.people += a.people;
c.thing += a.thing;
c.price += a.price;
x--;
}
c.put();
t = cin.nextInt();
}
System.out.println("0 0.00 0");//如果用System.out.println(0.00)只能打印出0.0，所以在打印的时候要以字符串的形式输出
}
}



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

120