Kat H.

asked • 05/24/21

Directions. Define a enumerated type Direction to make the following code work correctly.

Define a enumerated type Direction to make the following code work correctly. It should associate EAST with the value 0, NORTH with the value 90, WEST with 180 and SOUTH with 270.


Code:


#include <iostream>


using namespace std;


//Do not modify anything on or above the line below this

//YOUR_CODE_BELOW


//YOUR_CODE


//YOUR_CODE_ABOVE

//Do not modify anything on or below the line above this


int main()

{


int d1;

cin >> d1;


//map values over 360 and greater back into 0-359 range

d1 %= 360;


if(d1 == NORTH) {

cout << "North" << endl;

}

else if(d1 == SOUTH) {

cout << "South" << endl;

}

else if(d1 == EAST) {

cout << "East" << endl;

}

else if(d1 == WEST) {

cout << "West" << endl;

}

else {

cout << "Error" << endl;

}


}

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.