Advertisement
khisby

[Soal3]Converter_headings_to_bearings

Oct 9th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. // Khisby Al Ghofari, 06.2017.1.06852, Kelas B
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int heading,bearing;
  9.     cout << "\n=======================================================\n";
  10.     cout << "Welcome To \n";
  11.     cout << "Application Converter Compass Heading to Compass Bearing\n";
  12.     cout << "=========================================================\n \n";
  13.  
  14.     cout << "Input the degree of compass heading (0 until 360 degree) : ";
  15.     cin >> heading;
  16.  
  17.     cout << "\nIn compass bearing is ";
  18.     if(heading > 0 && heading <=360){
  19.         if(90 < heading && heading < 270){
  20.             cout << "South ";
  21.             bearing = 180 - heading;
  22.             if(bearing < 0){
  23.                 bearing = bearing * -1;
  24.                 cout << bearing << "' West";
  25.             }else{
  26.                 cout << bearing << "' East";
  27.             }
  28.         }else{
  29.             bearing = heading;
  30.             cout << "North ";
  31.             if(bearing > 0 && bearing <= 90){
  32.                 cout << bearing << "' East";
  33.             }else{
  34.                 bearing = 360 - heading;
  35.                 cout << bearing << "' West";
  36.             }
  37.         }
  38.     }else{
  39.         cout << "Your input is invalid";
  40.     }
  41.  
  42.     cout << "\n\n";
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement