Karesini Alma
Günde 5 saat, haftada 5 gün yarı zamanlı çalışırken, 5'in karesini sık sık hatırlaman gerekir. Koda her yere yazmak yerine, bunu kolaylaştıracak bir metot geliştirelim.
Bu egzersiz
Orta Düzey Java
kursunun bir parçasıdırEgzersiz talimatları
- Özel metodun
returnifadesine doğrutypever. - Bu metodu çağır ve sonucu
hoursolarak kaydet.
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");
}
}