总共添加两个数组

时间:2018-01-14 21:33:10

标签: java arrays

public class SeatCalculator {

static void display() {

    int AdultPrice = 6;
    int KidPrice = 3;       
    String uniqueID = UUID.randomUUID().toString();

        System.out.print("||              ID                ||  FirstName  ||  LastName ||  TelNum  ||  Adults  ||  Kids  ||  Total Price  ||  Total");

        String[] SetBooking1 = new String[4];           //Creats an array called SetBooking and gives it 8 identifiers. 
        SetBooking1[0] = uniqueID;
        SetBooking1[1] = "James"; 
        SetBooking1[2] = "hellier"; 
        SetBooking1[3] = "07707659810";

         int[] SetBookingValues = new int[4];
         SetBookingValues[0] = 3;
         SetBookingValues[1] = 4;
         SetBookingValues[2] = SetBookingValues[0] * AdultPrice + SetBookingValues[1] * KidPrice;
         SetBookingValues[3] = SetBookingValues[0] + SetBookingValues[1];

        String[] SetBooking2 = new String[4];           //Creats an array called SetBooking and gives it 8 identifiers. 
        SetBooking2[0] = uniqueID;
        SetBooking2[1] = "Kayleigh"; 
        SetBooking2[2] = "ray"; 
        SetBooking2[3] = "07706541234";

         int[] SetBookingValues2 = new int[4];
         SetBookingValues2[0] = 2;
         SetBookingValues2[1] = 3;
         SetBookingValues2[2] = SetBookingValues2[0] * AdultPrice + SetBookingValues2[1] * KidPrice;
         SetBookingValues2[3] = SetBookingValues2[0] + SetBookingValues2[1];



    System.out.println("\n"+Arrays.toString(SetBooking1) + Arrays.toString(SetBookingValues));
    System.out.println(Arrays.toString(SetBooking2) + Arrays.toString(SetBookingValues2));

   System.out.print("\nCurrent revenue gained from booking: "); 
   System.out.print("\nCurrent seats left: "  );

}

}

我要做的是计算SetBookingValues值[3]和SetBookingValues2值[3]以保持运行总计,基本上它是添加乘客然后参数将是设置确保不超过32个座位可以预订。

0 个答案:

没有答案