forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintDates.java
More file actions
40 lines (36 loc) · 1.05 KB
/
PrintDates.java
File metadata and controls
40 lines (36 loc) · 1.05 KB
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
37
38
39
40
//Exercise 4-3.
public class PrintDates
{
public static void main(String[] args)
{
String day = "Wednesday";
int date = 18;
String month = "April";
int year = 2018;
printAmerican(day, date, month, year);
System.out.println();
printEuropean(day, date, month, year);
}
public static void printAmerican(String day, int date, String month, int year)
{
System.out.println("American format:");
System.out.print(day);
System.out.print(", ");
System.out.print(month);
System.out.print(" ");
System.out.print(date);
System.out.print(", ");
System.out.println(year);
}
public static void printEuropean(String day, int date, String month, int year)
{
System.out.println("European format:");
System.out.print(day);
System.out.print(" ");
System.out.print(date);
System.out.print(" ");
System.out.print(month);
System.out.print(" ");
System.out.println(year);
}
}