BaşlayınÜcretsiz Başlayın

Yeni fiyat

Hükümetin mallarına yeni vergiler getirdi. Envanterindeki tüm fiyatları tek seferde güncellemek istiyorsun; her birinin değerine yarısını ekleyeceksin.

Bu egzersiz

Orta Düzey Java

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Fonksiyonuna doğru türü ver.
  • Argümanın bir buçuk katını döndür.
  • Uygun türde bir for döngüsü kullan.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

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]);
    }
  }
}
Kodu Düzenle ve Çalıştır