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

Squaring

Working part-time 5 hours a day, 5 days a week, you often have to remember the square of 5. Rather than putting it everywhere in our code, let's develop a method to make it easier.

Bu egzersiz

Intermediate Java

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

Egzersiz talimatları

  • Give the proper type to return for the custom method.
  • Call that method, saving the result as hours.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

class Squarer {
  // Give this function the proper return type
  static ____ squareOf5() {
    return 5 * 5;
  }

  public static void main(String[] args) {
    // Call the correct function name defined above
    int hours = ____();
    System.out.println("I'm working " + hours + " hours a week");
  }
}
Kodu Düzenle ve Çalıştır