-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample04.java
More file actions
36 lines (22 loc) · 856 Bytes
/
Example04.java
File metadata and controls
36 lines (22 loc) · 856 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
36
package nelioJavaExamples;
import java.util.Locale;
public class Example04 {
public static void main(String[] args) {
String product1 = "Computer";
String product2 = "Office Desk";
int age = 30;
int code = 5290;
char gender = 'F';
double price1 = 2100.0;
double price2 = 650.50;
double measure = 53.234567;
System.out.println("Products:");
System.out.printf("%s, wich price is $ %.2f%n", product1, price1);
System.out.printf("%s, wich price is $ %.2f%n", product2, price2);
System.out.printf("Record: %d years old, code %d and gender: %s", age, code, gender);
System.out.printf("Measure with eight decimal places: %f%n", measure);
System.out.printf("Rouded (three decimal places): %.3f%n", measure);
Locale.setDefault(Locale.US);
System.out.printf("US decimal point: %.3f", measure);
}
}