我想知道是否有可能將此代碼轉換爲for循環。我知道,你可以查找文本,但是,是有可能做類似變量inputRangeCity1,inputRangeCity2等東西..是否有可能將此代碼轉換爲for循環?
System.out.print("Enter maximum cell phone connectivity distance for city 1: ");
double inputRangeCity1 = user_input.nextDouble();
System.out.print("Enter maximum cell phone connectivity distance for city 2: ");
double inputRangeCity2 = user_input.nextDouble();
System.out.print("Enter maximum cell phone connectivity distance for city 3: ");
double inputRangeCity3 = user_input.nextDouble();
System.out.print("Enter maximum cell phone connectivity distance for city 4: ");
double inputRangeCity4 = user_input.nextDouble();
你可以使用數組 –