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.
Cet exercice fait partie du cours
Intermediate Java
Instructions
- Give the proper
type
toreturn
for the custom method. - Call that method, saving the result as
hours
.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
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");
}
}