Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbbd3ff8

Browse files
authored
Update Exercise_04_03.java
1 parent6e8e489 commitbbd3ff8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎Exercise_04/Exercise_04_03/Exercise_04_03.java‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,45 @@
66
distance between two cities. Divide the polygon into two triangles and use the
77
formula in Programming Exercise 2.19 to compute the area of a triangle.)
88
*/
9+
/*
10+
* To change this license header, choose License Headers in Project Properties.
11+
* To change this template file, choose Tools | Templates
12+
* and open the template in the editor.
13+
*/
14+
packageChapter_04;
15+
importjava.util.Scanner;
16+
/**
17+
*
18+
* @author ManuelJose
19+
*/
20+
publicclassEx04_03 {
21+
//Geography: estimate areas
22+
publicstaticvoidmain(String[]args) {
23+
//Atlanta: 40.41044,-99.40505000000002
24+
//Orlando: 28.5383355,-81.37923649999999
25+
//Savannah: 32.0835407,-81.09983419999998
26+
//Charlotte: 35.2270869,-80.84312669999997
27+
doublex0 =40.41044;
28+
doubley0 = -99.40505000000002;
29+
doublex1 =28.5383355;
30+
doubley1 = -81.37923649999999;
31+
doublex2 =32.0835407;
32+
doubley2 = -81.09983419999998;
33+
doublex3 =35.2270869;
34+
doubley3 = -80.84312669999997;
35+
36+
doubled1 =6371.01 *Math.acos(Math.sin(x0)*Math.sin(x1)+Math.cos(x0)*Math.cos(x1)*Math.cos(y0-y1));
37+
doubled2 =6371.01 *Math.acos(Math.sin(x1)*Math.sin(x2)+Math.cos(x1)*Math.cos(x2)*Math.cos(y1-y2));
38+
doubled3 =6371.01 *Math.acos(Math.sin(x0)*Math.sin(x2)+Math.cos(x0)*Math.cos(x2)*Math.cos(y0-y2));
39+
doubled4 =6371.01 *Math.acos(Math.sin(x2)*Math.sin(x3)+Math.cos(x2)*Math.cos(x3)*Math.cos(y2-y3));
40+
doubled5 =6371.01 *Math.acos(Math.sin(x3)*Math.sin(x0)+Math.cos(x3)*Math.cos(x0)*Math.cos(y3-y0));
41+
42+
doubles1 = (d1 +d2 +d3) /2;
43+
doublearea1 =Math.sqrt(s1 * (s1-d1)*(s1-d2)*(s1-d3));
44+
45+
doubles2 = (d3 +d4 +d5) /2;
46+
doublearea2 =Math.sqrt(s2 * (s2-d5)*(s2-d4)*(s2-d3));
47+
System.out.printf("Area total: %.2f km^2\n",area1+area2);
48+
49+
}
50+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp