3.16 (Random point) Write a program that displays a random coordinate in a rectangle.
The rectangle is centered at (0, 0) with width 100 and height 200.
The rectangle is centered at (0, 0) with width 100 and height 200.
public class ProgrammingEx3_16 { public static void main(String[] args) { double x = Math.random() * 100-50; double y = Math.random() * 200-100; System.out.print(x + "," + y); } }
why you subtract 100-50 and 200-100?
ReplyDeleteI would like to know as well why 100-50 and 200-100
ReplyDeleteI would like to know as well why 100-50 and 200-100
ReplyDelete