载货量最后为什么显示为0,载货车的名称也不显示
package 达达租车系统;
import java.util.Scanner;
class rongLiang {
int zairen;
int zaihuo;
}
class Car {
String name;
int rent;
rongLiang capacity;
}
public class dadadache {
static void showcar(){
}
public static void main(String[] args) {
Car car[]=new Car[6];
for(int i=0;i<6;i++){
car[i]=new Car();
car[i].capacity=new rongLiang();
}
car[0].name="奥迪A4";
car[1].name="马自达6";
car[2].name="皮卡雪6";
car[3].name="金龙";
car[4].name="松花江";
car[5].name="依维河";
car[0].rent=500;
car[1].rent=400;
car[2].rent=450;
car[3].rent=800;
car[4].rent=400;
car[5].rent=1000;
car[0].capacity.zairen=4;
car[1].capacity.zairen=4;
car[2].capacity.zairen=4;
car[2].capacity.zaihuo=2;
car[3].capacity.zairen=20;
car[4].capacity.zaihuo=4;
car[5].capacity.zaihuo=20;
System.out.println("欢迎使用达达租车系统\n你是否要租车:1是0否");
Scanner input=new Scanner(System.in);
int n=input.nextInt();
if(n==1){
System.out.println("你可租车的类型及其价目表:");
System.out.println("序号\t汽车名称\t 租金\t容量");
for(int i=0;i<6;i++){
System.out.println(i+1+"\t"+car[i].name+"\t"+car[i].rent+"元/天");
if(car[i].capacity.zaihuo==0)
System.out.println(" 载人:"+car[i].capacity.zairen+"人");
else if(car[i].capacity.zairen==0)
System.out.println(" 载货:"+car[i].capacity.zaihuo+"吨");
else
System.out.println(" 载人:"+car[i].capacity.zairen+"人 载货: "+car[i].capacity.zaihuo+"吨");
}
System.out.println("请输入你要租车的数量:");
n=input.nextInt();
int s[]=new int[n];
for(int i=1;i<=n;i++){
System.out.println("请输入第"+i+"辆车的序号:");
s[i-1]=input.nextInt();
}
System.out.println("请输入租车天数:");
int t=input.nextInt();
System.out.println("你的账单:");
System.out.println("***可载人的车有:");
int sum=0;
for(int i=0;i<n&&car[i].capacity.zairen!=0;i++){
System.out.println(car[s[i]-1].name+" ");
sum+=car[s[i]-1].capacity.zairen;
}
System.out.println("共载人"+sum+"人");
System.out.println("***可载货的车有:");
sum=0;
System.out.println("***********************");
for(int i=0;i<n&&car[i].capacity.zaihuo!=0;i++){
System.out.println("***********************");
System.out.println(car[s[i]-1].name+" ");
sum+=car[s[i]-1].capacity.zaihuo;
}
System.out.println("共载货:"+sum+"吨");
sum=0;
for(int i=0;i<n;i++)
sum+=car[s[i]-1].rent*t;
System.out.println("***租车总价格:"+sum+"元");
}
else
System.exit(0);
}
}