|
Need help
Hey everyone, this is my first post, and i was wondering if you could lend a hand with a problem i'am having with a class project. Im stuck on what to do. Any help would be greatly appreceited.
here is the project guidelines:
Description :
Write a program to read in a set of integer starting coordinates. Then read in a series of "directional moves". Each directional move is made up of a single character followed by a real number. The char is N, S, W, or E to indicate direction and the real number is how far to "move". When the user enters a 'q' for a direction the program will then print out the final location. (Do not allow further input)
Input :
First, a set of integers representing a starting location (X, Y). Then a series of directional moves as described above until a 'q' is entered. Case does not matter to the user.
Output :
Output is the final (X,Y) coordinates up to 2 decimal places. Account for the spaces as show in the sample run.
Sample Run :
Here is a sample execution:
% ./project2
Welcome to Project #1 : You Sunk My Battleship!
Enter starting (X, Y) coordinates : 12 5
Enter Move : N 5.0
Enter Move : S 3.3
Enter Move : E 13.3
Enter Move : W -2.33
Enter Move : Q
The final position is ( 27.63, 6.70 ).
%
Here is another sample run, more complicated:
% ./project2
Welcome to Project #1 : You Sunk My Battleship!
Enter starting (X, Y) coordinates : 12 5
Enter Move : N 3.4
Enter Move : S -2.6
Enter Move : E 5
Enter Move : w 9
Enter Move : w -3.2
Enter Move : w 0.1
Enter Move : e -0.33
Enter Move : n 5.12
Enter Move : s -3.141592654
Enter Move : q
The final position is ( 10.77, 19.26 ).
%
Here is ths actual code i have thus far. I' am very new to coding and any help would be greatly appreceited.
/////////////////////////////////////////////
#include <iostream>
void main () {
int x,y;
char dir;
cout << "Enter strating Coordinates (X, Y) :";
cin >> x, >> y;
do {
cout << "Enter Move :";
cin >> dir;
} while (dir !='q');
}
///////////////////////////////////////////////////
I know it is very raw, but i have no clue what to do from here. thank you again. If you have a better idea to write this code, please let me know and show.
Thanks
Robert
|