Functional Methods

Run Settings
LanguageJava
Language Version
Run Command
class Main { public static void main(String[] args){ firstMethod(); secondMethod(); System.out.println("The method multiplies any number between 1-10."); System.out.println(thirdMethod((int)Math.ceil(Math.random()*5))); } public static void firstMethod(){ System.out.println("The method states a fact in my opinion"); System.out.println("Dogs are the best!"); System.out.println("----------------------"); } public static void secondMethod(){ int BaseofTriangle = 8; int HeightofTriangle = 24; int AreaofTriangle = (BaseofTriangle * HeightofTriangle)/2; System.out.println("The method calculates the area of the triangle by the formula"); System.out.println("The area has a base "+BaseofTriangle+" and the height "+HeightofTriangle+", is equal to "+AreaofTriangle+"cm^2"); System.out.println("----------------------"); } public static int thirdMethod(int randomNum){ return (randomNum * 5); } }
Editor Settings
Theme
Key bindings
Full width
Lines