-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_3.cpp
43 lines (36 loc) · 1.1 KB
/
3_3.cpp
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
41
42
43
#include <iostream>
using namespace std;
const int SecondsPerMinute = 60;
const int MinutesPerDegree = 60;
int main()
{
int degrees;
int minutes;
int seconds;
cout << "Enter a latitude in degrees, minutes, and seconds: " << endl;
cout << "First, enter the degrees: ";
while(!(cin >> degrees) || (0 > degrees))
{
cout << "Error! Please enter a positive number: ";
cin.clear();
cin.sync();
}
cout << "Next, enter the minutes of arc: ";
while(!(cin >> minutes) || (0 > minutes))
{
cout << "Error! Please enter a positive number: ";
cin.clear();
cin.sync();
}
cout << "Finally, enter the seconds of arc: ";
while(!(cin >> seconds) || (0 > seconds))
{
cout << "Error! Please enter a positive number: ";
cin.clear();
cin.sync();
}
double degreesInFraction = (degrees * MinutesPerDegree * SecondsPerMinute + minutes * SecondsPerMinute + seconds) * 1.0 / (SecondsPerMinute * MinutesPerDegree);
cout << degrees << " degrees, " << minutes << " minutes, " << seconds << " seconds = " << degreesInFraction <<endl;
// system("pause");
return 0;
}