MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Intermediate Java

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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");
  }
}
Edit dan Jalankan Kode