Untitled

Run Settings
LanguageJava
Language Version
Run Command
class Main { public static void main(String[] args) { FunctionOne(); //this will print out a lucky number from 1 to 100 System.out.println("The hypotenuse of the right triangle with adjacent = 8cm and opposite = 6cm is: " +FunctionTwo(8,6) + "cm"); //this will calculate a hypotenuse with adjacent = 8 and opposite = 6 FunctionFour(); //this will calculate x using quadratic formula } //this function does not return value and it will generate a random number from 1 to 100 public static void FunctionOne(){ double randomnumber; randomnumber = Math.round(Math.random()*100); //Math.random() will randomly genarate number and it will time 100 then Math.round will round the number to it nearest value. System.out.println("The lucky number is: "+randomnumber); } //this function will calculate and return the value of hypotenuse public static double FunctionTwo(double a, double o){ return Math.hypot(a,o); //this method will return the value of square root of square A and square O } // this function will calculate x using quadratic formula public static void FunctionFour(){ //input the value of a,b,c double a =16; double b =2; double c = 1; //these are x1 and x2 for now they don't have any value double x1 =0; double x2 =0; double discriminant = Math.pow(b,2)-4*a*c; // this is discriminant used to identify if this equation will have root or not, and Math.pow(b,2) is b to the power of 2 if (discriminant >= 0){ //if the discriminant greater or equal to 0 it will calculate and print out x1 and x2 x1 = (-b+Math.sqrt(discriminant))/(2*a);//Math.sqrt is used to calculate the square root of the discriminant x2 = (-b-Math.sqrt(discriminant))/(2*a); System.out.println("x1 = "+ x1); System.out.println("x2 = "+ x2); }if (discriminant ==0){ //if the discriminant equal to 0 then it will print out there is one real root and it's value System.out.println("There is one real root: "+ x1); }else{ //if it's lower than 0 then there's no real root System.out.println("There are no real root!"); } } }
Editor Settings
Theme
Key bindings
Full width
Lines