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, kursun bir parçasıdır
Orta Düzey Java
Egzersiz talimatları
- Özel metodun
returnifadesine doğrutypever. - Bu metodu çağır ve sonucu
hoursolarak kaydet.
Uygulamalı etkileşimli egzersiz
Bu egzersizi bu örnek kodu tamamlayarak deneyin.
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");
}
}