package callcarapp;
import java.util.Scanner;
public class runapp {
public static void main(String[] args) {
int totalprice=0;
int totalvolum=0;
int totalweight=0;
System.out.println("欢迎使用答答租车系统:");
System.out.println("您是否要租车:1是 0否");
var input=new Scanner(System.in);
int x=input.nextInt();
zairen c1=new zairen("奥迪A4",500,4);
zairen c2=new zairen("马自达6",400,4);
zairhh c3=new zairhh("皮卡6",450,40,2);
zairen c4=new zairen("金龙",800,20);
zaihuo c5=new zaihuo("松花江",400,4);
if(x==1)
{
System.out.println("您可租车的类型及其价目表如下:");
c1.show();
c2.show();
c3.show();
c4.show();
c5.show();
System.out.println("您租车的数量为:");
Scanner input1=new Scanner(System.in);
int num=input1.nextInt();
for(int i=1;i<=num;i++)
{
System.out.println("请输入第"+i+"辆车的序号:");
Scanner input2=new Scanner(System.in);
int cnum=input2.nextInt();
switch(cnum)
{
case 1:{totalprice=+c1.getPrice();
totalvolum=+c1.getVolume();
break;}
case 2:{totalprice=+c2.getPrice();
totalvolum=+c2.getVolume();
break;}
case 3:{totalprice=+c3.getPrice();
totalvolum=+c3.getVolume();
totalweight=+c3.getWeight();break;}
case 4:{totalprice=+c4.getPrice();
totalvolum=+c4.getVolume();break;}
case 5:{totalprice=+c5.getPrice();
totalweight=+c5.getWeight();break;}
default:break;
}
}
System.out.println("您的账单如下:");
System.out.println("总价为:"+totalprice+"总人数为:"+totalvolum);
}
}
}
=+ 是赋值一个正数;
+= 是相加后赋值;
代码语法再看看。