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