Skip to content

Commit

Permalink
RandomSeq generator done
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypatel-208 committed Nov 23, 2023
1 parent 8eef431 commit 1c0ab63
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/RandomSeq.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.Random;

public class RandomSeq {
public static void main(String[] args) {
// Check if command line arguments are provided
if (args.length < 3) {
System.out.println("Usage: java RandomSeq <N> <lo> <hi>");
return;
}

// Parse command line arguments
int N = Integer.parseInt(args[0]);
double lo = Double.parseDouble(args[1]);
double hi = Double.parseDouble(args[2]);

// Create an instance of the Random class
Random random = new Random();

// Print N random values in (lo, hi)
for (int i = 0; i < N; i++) {
double x = lo + (hi - lo) * random.nextDouble();
System.out.printf("%.2f\n", x);
}
}
}

0 comments on commit 1c0ab63

Please sign in to comment.