Need help with school assignment
Im new to the whole java scene, and im in the learning stages. However, im now stuck in a situation.
I have a assignment wich is to be delivered tomorrow evening. And i am stuck at the second part of the assignment.
The assignment is as follows:
Problem 1 (40%)
Create a class Number Generator that can produce random numbers between a lower and an upper limit. The class should have the wholenumnber attributes lower limit, upper limit and number. The class should have a non-parameterized constructor that sets the lower limit and the number of 0 and upper limit of 100 The class will also have a parameterized constructor that has parameters for the lower limit and upper limit and assign these values to the corresponding attributes. The class will also have the following methods:
- Generate Number that produces a random number in the interval between the current value of attributes lower limit and upper limit and assign this random number to the attribute number. The method should have no parameters and returns no value.
o Use the following general formula to produce a random integer in the interval [low, high]:
low + (int) (Math.random () * ((high + 1) - low))
- GetNumber that returns the current value of number. The method has no parameters.
- GetLowerLimit and getUpperLimit that return values to the corresponding attributes and that have no parameters.
- ChangeLimits that takes in two parameters (newLowerLimit and newUpperLimit) to change the values on the border attributes. The boundaries should be altered only if the parameter newLowerLimit is less than parameter newUpperLimit.
Ok, the first assingment i think i have accomplished. Check out this:
Im now working on Problem 2 - and im stuck...! Can someone in here help me?
[B]public class NumberGenerator
public static void main( String args)
int lowerLimit = 0;
int upperLimit = 100;
int number = 0;
number = lowerLimit + (int) ( Math.random() * ((upperLimit + 1) - lowerLimit) );
public NumberGenerator (int lowerLimit, int upperLimit, int number )
int upperLimit, lowerLimit, number;
public void setUpperLimit(int upperLimit)
this.upperLimit = upperLimit;
public int getUpperLimit()
public void setLowerLimit(int lowerLimit)
this.lowerLimit = lowerLimit;
public int getLowerLimit()
public void setNumber(int Number)
this.number = number;
public int getNumbers()
public void changeLimits (int newLowerLimit, int newUpperLimit)
if (newLowerLimit > upperLimit)
lowerLimit = newLowerLimit;
upperLimit = newUpperLimit;
a) Create a program Random Numbers using an object of the Number Generator to generate 100 random numbers in the interval [0, 1000] and that puts them into an appropriate array.
b) Expand the program in a) by adding method
private static int largestNumber (int  array)
that array from a) as a parameter and returns the largest number in the array. Add sentences in main method that uses the method largestNumber the sensible way.
c) Expand the program in a) by adding the method number Statistics, which has array from a) as a parameter and returns a heltallsarray that includes how many times each of the numbers in the interval [0, 1000] occurs in the original array.
d) Expand the program in a) by adding the print method, which has array from c) as a parameter and prints a statistics in a clear manner - see the example of a (part of) to print the next page.
I cant post the picture of how it should look like since i havent posted enough posts :( send me a PM if you can help and ill send you the picture link!
Can somebody help me? ;-)