my assigment tell me to:

Write a program to randomly generate a 3-digit number N (it is ok if the number has
fewer than 3 digits). Create a number NN which is N placed next to it. Example, if
the number N is 263 then NN is 263263. If N is 7, NN is 007007. If N is 032, NN is
032032.
Next, divide NN by 7, and then by 11 and then 13.
Write the original number and the final result after the divisions.
Formula to randomly generate a 3-digit number is
(int)Math.floor(Math.random()*1000+1)

this is what I came up with but comes up with errors. Can I get some help

ublic class chapter3_problem_2 {

public static void main(String[] args) {
int n = (int)Math.floor(Math.random()*1000+1);
int nn = ("n" + "n");


System.out.println( +nn);

}
}

what am I doing wrong?

Uhm, you are trying to assign a string an integer. I don't really know what happens, but that migt be the problem. Try defining a String strNN, and then assigning it n + n (careful so you don't evalauate n + n). Then you could define int nn = Integer.parseInt(strNN) Edit: Also, use

tags from now on please

I hope this helps on your homework!
Emil Olofsson

You could use a java.text.DecimalFormat object to help format your integer into a string with 3 decimal places.

java.text.DecimalFormat threePlaces = new java.text.DecimalFormat("000");
strNN = threePlaces.Format(n) + threePlaces.Format(n);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.