Challenge: Method Overloading
Uppgift
Swipe to start coding
Practice Java method overloading by implementing a set of overloaded methods for calculating the area of different shapes.
- Create a public static method named
areathat takes twointparameters representing the width and height of a rectangle, and returns the area as anint. - Create another public static overloaded method named
areathat takes a singledoubleparameter representing the radius of a circle, and returns the area as adouble. - Create a third public static overloaded method named
areathat takes threedoubleparameters representing the sides of a triangle (a,b, andc), and returns the area as adoubleusing Heron's formula.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 4
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 8.33
Challenge: Method Overloading
Svep för att visa menyn
Uppgift
Swipe to start coding
Practice Java method overloading by implementing a set of overloaded methods for calculating the area of different shapes.
- Create a public static method named
areathat takes twointparameters representing the width and height of a rectangle, and returns the area as anint. - Create another public static overloaded method named
areathat takes a singledoubleparameter representing the radius of a circle, and returns the area as adouble. - Create a third public static overloaded method named
areathat takes threedoubleparameters representing the sides of a triangle (a,b, andc), and returns the area as adoubleusing Heron's formula.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 4
single