Purchase Solution

C++: Write a Class Coord that Includes Degrees

Not what you're looking for?

Ask Custom Question

In ocean navigation, locations are measured in degrees and minutes of latitude and longitude. For example, 149 degrees 34.8 minutes west longitude, and 17 degrees 31.5 minutes south latitude, to be written as 149°34.8' W, 17°31.5' S. There are 60 minutes in a degree. Longitudes are measured from 0 to 180 degrees, east or west from Greenwich, England. Latitude is measured from 0 to 90 degrees, north or south from the equator to the poles.

Write a class Coord that includes the members: degrees (int), minutes (float), and the direction character (N, S, E, or W) to represent both latitude and longitude (altogether 6 members). The class must have a constructor accepting 6 parameters and a toString() method that returns a string representation of the coordinate as a C++ string (not C string).

The main () program must allow the user to enter the coordinates one-by-one, create the Coord object, and apply its toString() method for displaying. You can use hex character constant 'xB0' for printing the degree symbol (°).

Purchase this Solution

Solution Summary

The solution writes a class Coord that includes degrees and minutes of latitudes and longitudes.

Solution Preview

Please see the attachment.

// Navigation.cpp

#include <iostream>
#include <sstream>
#include <string>
using namespace std;

class Coord {
public:
int longtitude_degree;
float longtitude_minute;
char longtitude_direction;
int latitude_degree;
float latitude_minute;
char latitude_direction;
Coord(int, float, char, int, float, char); // Constructor to accept 6 parameters
string toString(); // method for ...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.