答答租车,新人小白求大神指点还有没有需要改进的地方

http://img.mukewang.com/5727e47000015ea106030329.jpg

http://img.mukewang.com/5727e4860001d32209630283.jpg

http://img.mukewang.com/5727e49000016f9a09010273.jpg

http://img.mukewang.com/5727e49a000192db09500286.jpg

  1. package rent;

  2. import java.util.Scanner;

  3. public class Test {


  4. public static void main(String[] args) {

  5. // TODO Auto-generated method stub

  6. Car[] carforrent=new Car[]{new Bus("奥迪A4",500,0,4),new Bus("马自达6",400,0,4),new Pickup("皮卡雪6",450,2,4),

  7. new Bus("金龙",800,0,20),new Truck("松花江",400,4,0),new Truck("依维柯",1000,20,0)};

  8. System.out.println("欢迎使用答答租车系统:");

  9. System.out.println("您是否要租车:1是   0否");

  10. Scanner input=new Scanner(System.in);

  11. int choice=input.nextInt();

  12. if(choice==1){

  13. System.out.println("您可租车的类型以及价目表:");

  14. System.out.println("序号\t汽车名称\t租金\t\t容量");

  15. for(int i=0;i<carforrent.length;i++){

  16. System.out.print((i+1)+"\t"+carforrent[i].getName()+"\t"+carforrent[i].getRent()+"元/天\t");

  17. if(carforrent[i].getBusload()!=0)

  18. System.out.print("载人:"+carforrent[i].getBusload()+"人  ");

  19. if(carforrent[i].getBurden()!=0)

  20. System.out.print("载货:"+carforrent[i].getBurden()+"吨");

  21. System.out.println();

  22. }

  23. System.out.println("请输入您要租用汽车的数量:");

  24. Scanner input1=new Scanner(System.in);

  25. int num=input1.nextInt();

  26. int [] carID=new int[num];

  27. for(int i=0;i<num;i++){

  28. int j=i+1;

  29. System.out.println("请输入第"+j+"辆车的序号:");

  30. Scanner input2=new Scanner(System.in);

  31. carID[i]=input2.nextInt();

  32. }

  33. System.out.println("请输入租车天数:");

  34. Scanner input3=new Scanner(System.in);

  35. int days=input3.nextInt();

  36. System.out.println("您的账单:");

  37. int sumofbusload=0;

  38. int sumofburden=0;

  39. double rents=0;

  40. System.out.println("***可载人的车有:");

  41. for(int i=0;i<num;i++){

  42. if(carID[i]==1){

  43. System.out.print(carforrent[0].getName()+"  ");

  44. sumofbusload+=carforrent[0].getBusload();

  45. rents+=carforrent[0].getRent();

  46. }

  47. else if(carID[i]==2){

  48. System.out.print(carforrent[1].getName()+"  ");

  49. sumofbusload+=carforrent[1].getBusload();

  50. rents+=carforrent[1].getRent();

  51. }

  52. else if(carID[i]==3){

  53. System.out.print(carforrent[2].getName()+"  ");

  54. sumofbusload+=carforrent[2].getBusload();

  55. rents+=carforrent[2].getRent();

  56. }

  57. else if(carID[i]==4){

  58. System.out.print(carforrent[3].getName()+"  ");

  59. sumofbusload+=carforrent[3].getBusload();

  60. rents+=carforrent[3].getRent();

  61. }

  62. else continue;

  63. }

  64. System.out.println("共载人:"+sumofbusload+"人");

  65. System.out.println("***可载货的车有:");

  66. for(int i=0;i<num;i++){

  67. if(carID[i]==3){

  68. System.out.print(carforrent[2].getName()+"  ");

  69. sumofburden+=carforrent[2].getBurden();

  70. }

  71. else if(carID[i]==5){

  72. System.out.print(carforrent[4].getName()+"  ");

  73. sumofburden+=carforrent[4].getBurden();

  74. rents+=carforrent[4].getRent();

  75. }

  76. else if(carID[i]==6){

  77. System.out.print(carforrent[5].getName()+"  ");

  78. sumofburden+=carforrent[5].getBurden();

  79. rents+=carforrent[5].getRent();

  80. }

  81. else continue;

  82. }

  83. System.out.println("共载货:"+sumofburden+"吨");

  84. System.out.println("***租车总价格:"+rents*days);

  85. }

  86. else

  87. System.out.println("正退出答答租车系统");


沫语
浏览 1316回答 1
1回答

怪盗饭团

你这套系统要实现什么,哪些实现不了,这样才好让大家解答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java