-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eef431
commit 1c0ab63
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |