Skip to content

Commit 76519a0

Browse files
committed
hw3
1 parent d15dbf7 commit 76519a0

File tree

4 files changed

+43
-29
lines changed

4 files changed

+43
-29
lines changed

src/main/java/basic/AutoBoxingAndUnBoxing.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@
44
import java.util.List;
55

66
public class AutoBoxingAndUnBoxing {
7-
public static void main(String[] args) {
8-
List<Integer> list = new ArrayList<>();
97

10-
list.add(1);
11-
list.add(Integer.valueOf(1));
8+
public static void main(String[] args) {
9+
List<Integer> list = new ArrayList<>();
1210

13-
AutoBoxingAndUnBoxing autoBoxingAndUnBoxing = new AutoBoxingAndUnBoxing();
11+
list.add(1);
12+
list.add(Integer.valueOf(1));
1413

15-
Integer num = new Integer(10);
16-
autoBoxingAndUnBoxing.unboxingDemo(10);
14+
AutoBoxingAndUnBoxing autoBoxingAndUnBoxing = new AutoBoxingAndUnBoxing();
1715

18-
Integer sum = 0;
19-
long start = System.currentTimeMillis();
20-
for (int i = 0; i < 1_000_000_000; i++) {
21-
sum = sum + i;
22-
}
23-
long end = System.currentTimeMillis();
24-
System.out.println(end - start);
25-
26-
27-
int sum1 = 0;
28-
long start1 = System.currentTimeMillis();
29-
for (int i = 0; i < 1_000_000_000; i++) {
30-
sum1 = sum1 + i;
31-
}
32-
long end1 = System.currentTimeMillis();
33-
System.out.println(end1 - start1);
16+
Integer num = new Integer(10);
17+
autoBoxingAndUnBoxing.unboxingDemo(10);
3418

19+
Integer sum = 0;
20+
long start = System.currentTimeMillis();
21+
for (int i = 0; i < 1_000_000_000; i++) {
22+
sum = sum + i;
3523
}
24+
long end = System.currentTimeMillis();
25+
System.out.println(end - start);
3626

37-
public void unboxingDemo(Integer num) {
38-
System.out.println("num:" + num);
27+
int sum1 = 0;
28+
long start1 = System.currentTimeMillis();
29+
for (int i = 0; i < 1_000_000_000; i++) {
30+
sum1 = sum1 + i;
3931
}
32+
long end1 = System.currentTimeMillis();
33+
System.out.println(end1 - start1);
34+
35+
}
36+
37+
public void unboxingDemo(Integer num) {
38+
System.out.println("num:" + num);
39+
}
4040
}

src/main/java/basic/NumberLiteral.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public static void main(String[] args) {
88
System.out.println(0b1111);// 15
99
System.out.println(07777);//4095
1010
System.out.println(0XFFFF);// 65535
11+
System.out.println(1.11111E+2);// 111.111
1112

1213
long ssn = 232_45_4519;
1314
long creditCardNumber = 2324_4545_4519_3415L;

src/main/java/basic/softwaredevprocess/ComputeLoan.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import java.util.Scanner;
44

5-
public class ComputeLoan {
5+
public class ComputeLoan {
66

77
public static void main(String[] args) {
88
// Create a Scanner
@@ -24,14 +24,14 @@ public static void main(String[] args) {
2424
double loanAmount = input.nextDouble();
2525

2626
// Calculate payment
27-
double monthlyPayment = loanAmount * monthlyInterestRate / (1 - 1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12));
27+
double monthlyPayment =
28+
loanAmount * monthlyInterestRate / (1 - 1 / Math.pow(1 + monthlyInterestRate,
29+
numberOfYears * 12));
2830
double totalPayment = monthlyPayment * numberOfYears * 12;
2931

3032
// Display results
3133
System.out.println("The monthly payment is $" + (int) (monthlyPayment * 100) / 100.0);
3234
System.out.println("The total payment is $" + (int) (totalPayment * 100) / 100.0);
3335

3436
}
35-
36-
3737
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package homework.section3;
2+
3+
import java.util.Scanner;
4+
5+
public class CelsiusToFahrenheit {
6+
7+
public static void main(String[] args) {
8+
Scanner input = new Scanner(System.in);
9+
System.out.println("Enter a degree in Celsius: ");
10+
int celsius = input.nextInt();
11+
12+
}
13+
}

0 commit comments

Comments
 (0)