-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormatDemo.java
More file actions
19 lines (17 loc) · 783 Bytes
/
FormatDemo.java
File metadata and controls
19 lines (17 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* Created by Melissa on 20/08/2017.
*/
public class FormatDemo {
public static void main(String[] args) {
// Display the header of the table
System.out.printf("%-10s%-10s%-10s%-10s%-10s\n", "Degrees", "Radians", "Sine", "Cosine", "Tangent");
// Display values for 30 degrees
int degrees = 30;
double radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", degrees, radians, Math.sin(radians), Math.cos(radians), Math.tan(radians));
// Display Values for 60 degrees
degrees = 60;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", degrees, radians, Math.sin(radians), Math.cos(radians), Math.tan(radians));
}
}