Main Methods in Java

Hi There

So I am trying do some Math Methods inside of a loop. Problem here, is that I really don't know how to call Math methods, and then make it work for me. I am also supposed have a random digit using the random method put inside of there. I know how to use the loop, just how am I able to call my Math methods and use them with the random method. Here is the email I sent to my teacher, and here also is her reply:

public class MyClass { public static void main(String args[]) { int x=10; int y=25; int z=x+y; for(int i = 1; i <= 10; i++) {

System.out.println("The sum of " + x + " and " + y + " is " + z);
}

}

}

The best I could do is the loop. I am really confused on how to call the Math Method, or doing the Random Method.

That was my email to her. Here's my reply that I got back:

Jesse:

Yes, this is a good loop. It will print the same sentence (with the same numbers) ten times. If you include i in the print statement, you could see it changing as the program goes through the loop.

To use a library of methods (like Math) you need to call the methods it offers using the dot operator:

Math.max(5, 10) will return 10, for example. Math.sqrt(x) will return the square root of the value stored in the x variable.

You can put calls to methods inside other statements:

if Math.max(x,y) > 0

or

System.out.println(“This is the maximum value: “ + Math.max(i,j) + “.”);

See if you can add some Math method calls before your loop, using the variables x, y, or z as parameters. Be sure to include print statements so you can see the results!

I am doing this class online, so I hoped that she would teach me actually how to do this. She's not. I have not really learned how to call methods, or how to make something a perimeter, as she had suggested. I am planning on doing a Zoom Meeting this afternoon with her. What am I supposed to do here?

Ok it is fine not to know how to do something in programming. Happens to us all. However, one skill you will want to develop is how to find the answer. Have you tried doing a Google search for “java Math examples”?

You will get results like the one below…

Then the next thing you do is you try out the examples in a clean project and see if you can get it to work. Once it works, you play around with it. Change some numbers, try calling another method using the same format shown in the website examples.

Part of programming is experimenting and trying things out. Start SIMPLE and then once you learn how things work, you steadily grow by making examples more complex.

Check out the website, try it out and let us know how it goes. :slight_smile:

1 Like

Like I told your brother in another thread, programming is about learning patterns and being able to apply them. Part of that is to learn the difference between a class and a method, which is part of your problem.

A class is a collection of related objects. They could be variables, could be methods, could be other classes. A method on the other hand is a block of code which accomplishes a specific purpose.

Math is a CLASS. It has various methods which can be utilized, including sum, random, etc. Each of those methods returns a value of some sort.

Referencing her response, she’s provided a couple examples of various math methods.

  • Math.max(5, 10)
  • Math.sqrt(x)

She’s right that you can either assign a method result to a variable, or just use it in operations. These do the same thing essentially (there is a difference in #1 will assign a “permanent” memory space for the variable where the 2nd throws the memory space away sooner)

int maxValue = Math.max(x, y)
if (maxValue > 10) {
   // do something here
}
if (Math.max(x, y) > 10) {
   // do something here
}

If you’re unsure how to use the methods in the Math class, here is a solid reference.
Each method has examples under them which you should be able to copy/paste and run to see the results. https://www.javatpoint.com/java-math

I’m back. I need a little bit of help. Here’s my code:

package Lesson;
import java.lang.Math;
public class MainMethods {

	//Naming own Int's. Separate public area
	    static int AddUp(int i, int j) {
	       return(i + j);
	    }
	   static int Multiply(int k, int u) {
	       return(k * u);
	   }
	    static int Subtraction(int a, int b){
	        return(a - b);
	    }
	    static int Divide(int c, int h) {
	        return(c / h); 
	    }
	    
	
	    
	   
	    
	    //Assigning Int's with value and function
	    public static void main(String args[]) {
	      int x=10;
	      int y=25;
	      int z=x+y;
	      
	      int a = -1; 
	      int s = 8; 
	      int d = a+s;
	      
	      int g = -54; 
	      int t = 23; 
	      int h = g*t; 
	      
	      int min = 11; 
	      int max = -1;
	      int total = 0;
	      
	      //doubles
	      double d1 = 5.0; 
	      double d2 = 6.5; 
	      double d3 = 7; 
	      double d4 = -6.0;
	      
	      double d5 = -4.7;
	      double d6 = 2.3;
	      double d7 = -0.7;
	      double d8 = -7.7;
	      
	      double l = 5.7;
	      
	      double w = Math.random(); 
	      double v = Math.random(); 
	      double b = Math.random();
	      
	     

	      //Making Statements with calling Math Methods
	      for(int i = 1; i <= 10; i++) {
	           System.out.println("The sum of " + x + " and " + y + " is " + z);
	       }
	       //Things that I am supposed to use
	       /*
	       Math.max(); //done
	       Math.max(); //done
	       Math.random(); //done
	       Math.sqrt(); //done
	       Math.pow(); //done
	       */
	       
	       /*
	       double pow(double a, double b); //Use 3.0 and 2.0 //Done
	       double sqrt(double x); //Use 25.0 //Done
	       int max(int a, int b); //Use 6 and 2 //Done
	       double max(double a, double b); //Use -50.0 and 7.0 //Done
	       static double random(); //Done
	       */
	       //System.out.println Statements
	       System.out.println();
	       System.out.println("The maximum value of x and y: " + Math.max(x,y)); //Math.max
	       System.out.println();
	       System.out.println("That maximum value of a and g: " + Math.max(a,g)); //Math.max
	       System.out.println();
	       System.out.println("The addition of x and y: " + AddUp (x, y)); //Declaring own int
	       System.out.println();
	       System.out.println("The multiplication of a and s: " + Multiply (a, s)); //Declaring own int
	       System.out.println();
	       System.out.println("The subtraction of a and s: " + Subtraction(a, s)); //Declaring own int
	       System.out.println();
	       		int randomInt = (int)(11.0 * Math.random());
	       		
	       System.out.println("Random number from -1 and 11: "); //Random digits
	       		int random_int = (int)Math.floor(Math.random() * (max - min) + min / 1000d);
       			System.out.println(random_int);
	       System.out.println();
	       System.out.println("The division of g and t: " + Divide(g, t)); //Declaring own int
	       System.out.println();
	       System.out.println("Math.pow(d1, d2): " + Math.pow(d1, d2));//Double pow
	       System.out.println();
	       System.out.println("Math.max(d5, d8): " + Math.max(d5, d8));//Double max
	       System.out.println();
	       System.out.println("Math.sqrt(z): " + Math.sqrt(z));//Math.sqrt
	       System.out.println(); 
	       System.out.println("Math.sqrt(l): " + Math.sqrt(l));//Double Math.sqrt
	       System.out.println();
	       System.out.println("Math.max("+ g +","+ t +") = " + Math.max(g, t)); //Double Math.max
	       System.out.println(); 
	       System.out.println("double w, double b: " + w + b); //Double static double random();
	    }

}

Here’s my issue:
I need to have the Math.random(); method to be divided by 1000, but keep it between -1 and 11. That’ definatly an issue. I also need to call it(think I’ve already done that) then return it. Don’t know if I already did that last part, though.
I also need to set my three int’s(int max, int min, and int total) under a method called randomStudy.
Here’s the instructions if that helps any.

Add a method to your program called randomStudy that has no parameters and returns no value. In this method, do the following:
Declare three int variables: total, min, and max. Set total to 0, min to 11, and max to -1.
Create a loop that will run 1,000 times. In the body of the loop, generate a random int value between 1 and 10, inclusive. Add this number to your total. If this number is less than min, update min with the new number. If it is greater than max, update max with the new number.
After the loop, display the following:

Min value: x
Max value: y
Average: z
Replace x and y with your min and max values. Calculate z by dividing your total by 1000d.
Call your new randomStudy method from the main method.

I need help before 3 o’clock today. Please, any and all advice is welcomed. I appreciate @DaveMaxwell and @Martyr2 for helping me out earlier. Thanks, guys. Really helped.
I checked them out, and it helped a bit. I didn’t do exactly as you suggested, @DaveMaxwell , but I think I still accomplished the idea.
Again, thanks in advance, and in the present for everyone. Hope y’all have a great day, and happy programing to you all

@jcaldwell11 I’m sure it has been mentioned before that you need to format your code for the forums. To do so you can either select all the code and click the </> button, or type 3 backticks ``` on a separate line both before and after the block of code.

I have done it for you this time. Please remember in future.

1 Like

Did you read that one right? I’m not sure how to pull that one off, to be honest. Keeping the random between -1 and 11 is simple (see code below) but keeping a result / 1000 between that range? Good luck with that.

This one is pretty straight forward if you think it through and you’ve done most of it already.

public static void randomStudy() {
	// declare your variables
	int min = 11;
	int max = -1;
	int total = 0;

	// loop 1000 times
	for (int x = 0; x < 1000; x++) {
		total += 1 + (Math.random() * 10);  
	}
	// replace min/max if needed
	if (total < min) {
		// shouldn't fire based on loop and conditions....
		min = total;
	}
	if (total > max) { 
		max = total;
	}
	// display out results
	System.out.println("Min value: " + min);
	System.out.println("Max value: " + max);
	System.out.println("Average: " + (total / 1000));
}

Isn’t that -1000 + Math.random() * 12001?

Any result from that devided by 100 falls in the range (-1, 11).

(I use 12001 to make up for Math.random() never returning 1).

1 Like

Thanks, @Gandalf

That’s brilliant @DaveMaxwell :joy:

At least someone recognizes :lol:

4 Likes

Here’s my new code:

package Lesson;
import java.lang.Math;
    int min = -1; 
    int max = 11; 
    int total = 0;
// loop 1000 times
	for (int x = 0; x < 1000; x++) {
		total += 1 + (Math.random() * 10);  
	}
	// replace min/max if needed
	if (total < min) {
		min = total;
	}
	if (total > max) { 
		max = total;
	}
	// display out results
	System.out.println("Min value: " + min);
	System.out.println("Max value: " + max);
	System.out.println("Average: " + (total / 1000));
}

public class MainMethods {

	//Naming own Int's. Separate public area
	    static int AddUp(int i, int j) {
	       return(i + j);
	    }
	   static int Multiply(int k, int u) {
	       return(k * u);
	   }
	    static int Subtraction(int a, int b){
	        return(a - b);
	    }
	    static int Divide(int c, int h) {
	        return(c / h); 
	    }
	    
	  
	      
	    }
	    
	   
	    
	    //Assigning Int's with value and function
	    public static void main(String args[]) {
	      int x=10;
	      int y=25;
	      int z=x+y;
	      
	      int a = -1; 
	      int s = 8; 
	      int d = a+s;
	      
	      int g = -54; 
	      int t = 23; 
	      int h = g*t; 
	      
	     
	      
	      //doubles
	      double d1 = 5.0; 
	      double d2 = 6.5; 
	      double d3 = 7; 
	      double d4 = -6.0;
	      
	      double d5 = -4.7;
	      double d6 = 2.3;
	      double d7 = -0.7;
	      double d8 = -7.7;
	      
	      double l = 5.7;
	      
	      double w = Math.random(); 
	      double v = Math.random(); 
	      double b = Math.random();
	      
	     

	      //Making Statements with calling Math Methods
	      for(int i = 1; i <= 10; i++) {
	           System.out.println("The sum of " + x + " and " + y + " is " + z);
	       }
	       //Things that I am supposed to use
	       /*
	       Math.max(); //done
	       Math.max(); //done
	       Math.random(); //done
	       Math.sqrt(); //done
	       Math.pow(); //done
	       */
	       
	       /*
	       double pow(double a, double b); //Use 3.0 and 2.0 //Done
	       double sqrt(double x); //Use 25.0 //Done
	       int max(int a, int b); //Use 6 and 2 //Done
	       double max(double a, double b); //Use -50.0 and 7.0 //Done
	       static double random(); //Done
	       */
	       //System.out.println Statements
	       System.out.println();
	       System.out.println("The maximum value of x and y: " + Math.max(x,y)); //Math.max
	       System.out.println();
	       System.out.println("That maximum value of a and g: " + Math.max(a,g)); //Math.max
	       System.out.println();
	       System.out.println("The addition of x and y: " + AddUp (x, y)); //Declaring own int
	       System.out.println();
	       System.out.println("The multiplication of a and s: " + Multiply (a, s)); //Declaring own int
	       System.out.println();
	       System.out.println("The subtraction of a and s: " + Subtraction(a, s)); //Declaring own int
	       System.out.println();
	       		int randomInt = (int)(11.0 * Math.random());
	       		
	       System.out.println("Random number from -1 and 11: "); //Random digits
	       		int random_int = (int)Math.floor(Math.random() * (max - min) + min / 1000d);
       			System.out.println(random_int);
	       System.out.println();
	       System.out.println("The division of g and t: " + Divide(g, t)); //Declaring own int
	       System.out.println();
	       System.out.println("Math.pow(d1, d2): " + Math.pow(d1, d2));//Double pow
	       System.out.println();
	       System.out.println("Math.max(d5, d8): " + Math.max(d5, d8));//Double max
	       System.out.println();
	       System.out.println("Math.sqrt(z): " + Math.sqrt(z));//Math.sqrt
	       System.out.println(); 
	       System.out.println("Math.sqrt(l): " + Math.sqrt(l));//Double Math.sqrt
	       System.out.println();
	       System.out.println("Math.max("+ g +","+ t +") = " + Math.max(g, t)); //Double Math.max
	       System.out.println(); 
	       System.out.println("double w, double b: " + w + b); //Double static double random();
	    }

}

This is saying that all of my code, if not most, is now incorrect. This is why, I think.
I put the public static void randomStudy() outside of my public class and it is saying I have 69 or so errors because of it. Please look at my code above, and is there a better alternative to have the same thing, but have it all in a public static void area, without having to create another. The only way I can imagine this is calling my original public static void randomStudy();, but I don’t know whether or not that’ll affect some of my code

  1. You’re missing the method declaration (the public static void randomStudy() { portion).
  2. You’ve put the code outside the class, which means it’ll be inaccessible.

Take everything between the following two lines out.

import java.lang.Math;

and

public class MainMethods {

Copy the ENTIRE block of code I provided you in post #6 and paste it BEFORE the last closing curly bracket. This makes it available in your class. Then in the last line of main(), add this to actually call the method.

randomStudy();

Here’s my new code:


package Lesson;
import java.lang.Math;
    
public class MainMethods {

	//Naming own Int's. Separate public area
	    static int AddUp(int i, int j) {
	       return(i + j);
	    }
	   static int Multiply(int k, int u) {
	       return(k * u);
	   }
	    static int Subtraction(int a, int b){
	        return(a - b);
	    }
	    static int Divide(int c, int h) {
	        return(c / h); 
	    }
	    
	  
	      
	    
	    
	   
	    
	    //Assigning Int's with value and function
	    public static void main(String args[]) {
	      int x=10;
	      int y=25;
	      int z=x+y;
	      
	      int a = -1; 
	      int s = 8; 
	      int d = a+s;
	      
	      int g = -54; 
	      int t = 23; 
	      int h = g*t; 
	      
	     
	      
	      //doubles
	      double d1 = 5.0; 
	      double d2 = 6.5; 
	      double d3 = 7; 
	      double d4 = -6.0;
	      
	      double d5 = -4.7;
	      double d6 = 2.3;
	      double d7 = -0.7;
	      double d8 = -7.7;
	      
	      double l = 5.7;
	      
	      double w = Math.random(); 
	      double v = Math.random(); 
	      double b = Math.random();
	      
	     

	      //Making Statements with calling Math Methods
	      for(int i = 1; i <= 10; i++) {
	           System.out.println("The sum of " + x + " and " + y + " is " + z);
	       }
	       //Things that I am supposed to use
	       /*
	       Math.max(); //done
	       Math.max(); //done
	       Math.random(); //done
	       Math.sqrt(); //done
	       Math.pow(); //done
	       */
	       
	       /*
	       double pow(double a, double b); //Use 3.0 and 2.0 //Done
	       double sqrt(double x); //Use 25.0 //Done
	       int max(int a, int b); //Use 6 and 2 //Done
	       double max(double a, double b); //Use -50.0 and 7.0 //Done
	       static double random(); //Done
	       */
	       //System.out.println Statements
	       System.out.println();
	       System.out.println("The maximum value of x and y: " + Math.max(x,y)); //Math.max
	       System.out.println();
	       System.out.println("That maximum value of a and g: " + Math.max(a,g)); //Math.max
	       System.out.println();
	       System.out.println("The addition of x and y: " + AddUp (x, y)); //Declaring own int
	       System.out.println();
	       System.out.println("The multiplication of a and s: " + Multiply (a, s)); //Declaring own int
	       System.out.println();
	       System.out.println("The subtraction of a and s: " + Subtraction(a, s)); //Declaring own int
	       System.out.println();
	       System.out.println("The division of g and t: " + Divide(g, t)); //Declaring own int
	       System.out.println();
	       System.out.println("Math.pow(d1, d2): " + Math.pow(d1, d2));//Double pow
	       System.out.println();
	       System.out.println("Math.max(d5, d8): " + Math.max(d5, d8));//Double max
	       System.out.println();
	       System.out.println("Math.sqrt(z): " + Math.sqrt(z));//Math.sqrt
	       System.out.println(); 
	       System.out.println("Math.sqrt(l): " + Math.sqrt(l));//Double Math.sqrt
	       System.out.println();
	       System.out.println("Math.max("+ g +","+ t +") = " + Math.max(g, t)); //Double Math.max
	       System.out.println(); 
	       System.out.println("double w, double b: " + w + b); //Double static double random();

	

}
 public static void randomStudy() {
	// declare your variables
	int min = 11;
	int max = -1;
	int total = 0;

	// loop 1000 times
	for (int x = 0; x < 1000; x++) {
		total += 1 + (Math.random() * 10);  
	}
	// replace min/max if needed
	if (total < min) {
		// shouldn't fire based on loop and conditions....
		min = total;
	}
	if (total > max) { 
		max = total;
	}
}
    return {
	 randomStudy();
}
}


I have a few errors now instead of a lot. What am I missing here that will fix it?

Here’s my error:
image

Why is it illegal start?

Because you weren’t diligent in following the instructions I gave you.

package Lesson;
import java.lang.Math;

public class MainMethods {

    //Naming own Int's. Separate public area
    static int AddUp(int i, int j) {
        return(i + j);
    }
    static int Multiply(int k, int u) {
        return(k * u);
    }
    static int Subtraction(int a, int b){
        return(a - b);
    }
    static int Divide(int c, int h) {
        return(c / h); 
    }

    //Assigning Int's with value and function
    public static void main(String args[]) {
        int x=10;
        int y=25;
        int z=x+y;
        
        int a = -1; 
        int s = 8; 
        int d = a+s;
        
        int g = -54; 
        int t = 23; 
        int h = g*t; 
        
        //doubles
        double d1 = 5.0; 
        double d2 = 6.5; 
        double d3 = 7; 
        double d4 = -6.0;
        
        double d5 = -4.7;
        double d6 = 2.3;
        double d7 = -0.7;
        double d8 = -7.7;
        
        double l = 5.7;
        
        double w = Math.random(); 
        double v = Math.random(); 
        double b = Math.random();

        //Making Statements with calling Math Methods
        for(int i = 1; i <= 10; i++) {
            System.out.println("The sum of " + x + " and " + y + " is " + z);
        }
        //Things that I am supposed to use
        /*
        Math.max(); //done
        Math.max(); //done
        Math.random(); //done
        Math.sqrt(); //done
        Math.pow(); //done
        */
        
        /*
        double pow(double a, double b); //Use 3.0 and 2.0 //Done
        double sqrt(double x); //Use 25.0 //Done
        int max(int a, int b); //Use 6 and 2 //Done
        double max(double a, double b); //Use -50.0 and 7.0 //Done
        static double random(); //Done
        */
        //System.out.println Statements
        System.out.println();
        System.out.println("The maximum value of x and y: " + Math.max(x,y)); //Math.max
        System.out.println();
        System.out.println("That maximum value of a and g: " + Math.max(a,g)); //Math.max
        System.out.println();
        System.out.println("The addition of x and y: " + AddUp (x, y)); //Declaring own int
        System.out.println();
        System.out.println("The multiplication of a and s: " + Multiply (a, s)); //Declaring own int
        System.out.println();
        System.out.println("The subtraction of a and s: " + Subtraction(a, s)); //Declaring own int
        System.out.println();
        System.out.println("The division of g and t: " + Divide(g, t)); //Declaring own int
        System.out.println();
        System.out.println("Math.pow(d1, d2): " + Math.pow(d1, d2));//Double pow
        System.out.println();
        System.out.println("Math.max(d5, d8): " + Math.max(d5, d8));//Double max
        System.out.println();
        System.out.println("Math.sqrt(z): " + Math.sqrt(z));//Math.sqrt
        System.out.println(); 
        System.out.println("Math.sqrt(l): " + Math.sqrt(l));//Double Math.sqrt
        System.out.println();
        System.out.println("Math.max("+ g +","+ t +") = " + Math.max(g, t)); //Double Math.max
        System.out.println(); 
        System.out.println("double w, double b: " + w + b); //Double static double random();
        randomStudy();
    }

    public static void randomStudy() {
	    // declare your variables
	    int min = 11;
	    int max = -1;
	    int total = 0;

	    // loop 1000 times
	    for (int x = 0; x < 1000; x++) {
		    total += 1 + (Math.random() * 10);  
	    }
	    // replace min/max if needed
	    if (total < min) {
		    // shouldn't fire based on loop and conditions....
		    min = total;
	    }
	    if (total > max) { 
    		max = total;
	    }
        // display out results
	    System.out.println("Min value: " + min);
	    System.out.println("Max value: " + max);
	    System.out.println("Average: " + (total / 1000));
    }    
}

Though to be consistent, you should probably tweak it to move randomStudy to be an internal method like you have the rest

package Lesson;
import java.lang.Math;

public class MainMethods {

    //Naming own Int's. Separate public area
    static int AddUp(int i, int j) {
        return(i + j);
    }
    static int Multiply(int k, int u) {
        return(k * u);
    }
    static int Subtraction(int a, int b){
        return(a - b);
    }
    static int Divide(int c, int h) {
        return(c / h); 
    }
    static void randomStudy() {
	    // declare your variables
	    int min = 11;
	    int max = -1;
	    int total = 0;

	    // loop 1000 times
	    for (int x = 0; x < 1000; x++) {
		    total += 1 + (Math.random() * 10);  
	    }
	    // replace min/max if needed
	    if (total < min) {
		    // shouldn't fire based on loop and conditions....
		    min = total;
	    }
	    if (total > max) { 
    		max = total;
	    }
        // display out results
	    System.out.println("Min value: " + min);
	    System.out.println("Max value: " + max);
	    System.out.println("Average: " + (total / 1000));
    }    

    //Assigning Int's with value and function
    public static void main(String args[]) {
        int x=10;
        int y=25;
        int z=x+y;
        
        int a = -1; 
        int s = 8; 
        int d = a+s;
        
        int g = -54; 
        int t = 23; 
        int h = g*t; 
        
        //doubles
        double d1 = 5.0; 
        double d2 = 6.5; 
        double d3 = 7; 
        double d4 = -6.0;
        
        double d5 = -4.7;
        double d6 = 2.3;
        double d7 = -0.7;
        double d8 = -7.7;
        
        double l = 5.7;
        
        double w = Math.random(); 
        double v = Math.random(); 
        double b = Math.random();

        //Making Statements with calling Math Methods
        for(int i = 1; i <= 10; i++) {
            System.out.println("The sum of " + x + " and " + y + " is " + z);
        }
        //Things that I am supposed to use
        /*
        Math.max(); //done
        Math.max(); //done
        Math.random(); //done
        Math.sqrt(); //done
        Math.pow(); //done
        */
        
        /*
        double pow(double a, double b); //Use 3.0 and 2.0 //Done
        double sqrt(double x); //Use 25.0 //Done
        int max(int a, int b); //Use 6 and 2 //Done
        double max(double a, double b); //Use -50.0 and 7.0 //Done
        static double random(); //Done
        */
        //System.out.println Statements
        System.out.println();
        System.out.println("The maximum value of x and y: " + Math.max(x,y)); //Math.max
        System.out.println();
        System.out.println("That maximum value of a and g: " + Math.max(a,g)); //Math.max
        System.out.println();
        System.out.println("The addition of x and y: " + AddUp (x, y)); //Declaring own int
        System.out.println();
        System.out.println("The multiplication of a and s: " + Multiply (a, s)); //Declaring own int
        System.out.println();
        System.out.println("The subtraction of a and s: " + Subtraction(a, s)); //Declaring own int
        System.out.println();
        System.out.println("The division of g and t: " + Divide(g, t)); //Declaring own int
        System.out.println();
        System.out.println("Math.pow(d1, d2): " + Math.pow(d1, d2));//Double pow
        System.out.println();
        System.out.println("Math.max(d5, d8): " + Math.max(d5, d8));//Double max
        System.out.println();
        System.out.println("Math.sqrt(z): " + Math.sqrt(z));//Math.sqrt
        System.out.println(); 
        System.out.println("Math.sqrt(l): " + Math.sqrt(l));//Double Math.sqrt
        System.out.println();
        System.out.println("Math.max("+ g +","+ t +") = " + Math.max(g, t)); //Double Math.max
        System.out.println(); 
        System.out.println("double w, double b: " + w + b); //Double static double random();
        randomStudy();
    }
}

That code, as is, works. Both versions.

@DaveMaxwell ,
Sir, you are truly amazing. Thanks for all of your help, and tips through out this entire process.
Everyone here who has helped, thanks.

1 Like