-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom.java
More file actions
35 lines (20 loc) · 813 Bytes
/
random.java
File metadata and controls
35 lines (20 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Jain Aarush
// February 27th
// Rounding number and Random number generator assignment
// Mrs.Strelkovska ICS3U7
public class random {
public static void main(String[] args) {
// rounding assignment
double expression1 = 1 / 4 + 10 - 3 / (5 - 0.00024);
// round number to 2 decimal places
double rounded1 = (Math.round(expression1 * 100)) / 100.0;
System.out.format("%.2f\n", rounded1);
double expression2 = (Math.pow(27.3 + 0.3, 3) - ((3 + 15.3) / (1.22 / 2)) + 15.34876) / (Math.sqrt(6));
double rounded2 = (Math.round(expression2 * 100)) / 100.0;
System.out.println(rounded2);
// random number assignment
System.out.println((int)(Math.random() * 21));
System.out.println((int)((Math.random() * 10) - 6));
System.out.println((int)((int)(Math.random() * 7) * 10));
}
}