MulaiMulai sekarang secara gratis

New price

Your government just introduced new taxes on your goods. You want to update all of the prices in your inventory at one time, adding half of its value to it.

Latihan ini adalah bagian dari kursus

Intermediate Java

Lihat Kursus

Petunjuk latihan

  • Give the correct type to your function.
  • Return one and a half multiple of the argument.
  • Use the appropriate type of for loop.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

class PriceCalculator {
  // Give the correct type to your function
  static ____ oneAndAHalf(double a) {
    // Use the proper operations to get the result
    return ____;
  }

  public static void main(String[] args) {
    double[] numbers = {76, 38.3, 10, 42, 98.5, 84, 50, 72.2, 98, 96};

    // Use the congruous type of for loop
    for (____) {
      numbers[i] = oneAndAHalf(numbers[i]);
      System.out.println(numbers[i]);
    }
  }
}
Edit dan Jalankan Kode