Hello everyone. I am taking my first c++ class and i'm unfortunately not very skilled when it comes to coding and I am having trouble getting the hang of how it works. Our assignment is to create an application, AgentInfo, to track some secret agents. The 4 secret agents and their locations are:
Name | City | Country | Coordinates
BOB | Moscow | Russia | 55.778 N x 37.617 E
LINDA | Washington DC | US | 38.907 N x 77.036 W
JACK | London | UK | 51.507 N x 0.12787 W
SASHA | Melbourne | Australia | 25.274 S x 133.7751 E
The AgentInfo application needs a password in order to start. Expected behavior when running the program will be to include the password and name of the agent in the command line, which in turn will reveal their location info if the password correct. Entering an incorrect password will exit the application.
Command Line signature: AgentInfo <Password> <Agent Name>
Example:
> AgentInfo myPassword1 BOB
This will return the following info:
Agent Name: BOB
Country: Russia
City: Moscow
Location Coordinates: 55.778 N x 37.617 E
Here is what I have so far but i keep getting a segmentation fault: 11. Not sure what that means. Any help is greatly appreciated
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
|
#include <iostream>
#include <string>
using namespace std;
int main(int parameterCount, char* inputs[]){
char row;
char column;
string agentInfo [4][3] = {
{"Moscow", "Russia", "55.778Nx37.617E"},
{"Washington DC", "US", "38.90Nx77.036W"},
{"London", "UK", "51.507Nx0.12787W"},
{"Melbourne", "Australia", "25.274Sx133.7751E"}
};
string input1 = inputs[1];
string input2 = inputs[2];
if(input1 == "ENTER" || input1 == "enter"){
}else{
cout << "Invalid information" << endl;
}
for(int j = 0; j < column; ++j){
for(int i = 0; i < row; ++i){
if(input1 == "BOB" || input1 == "bob" || input1 == "Bob"){
row = 0;
}else if(input2 == "LINDA" || input2 == "linda" || input2 == "Linda"){
row = 1;
}else if(input2 == "JACK" || input2 == "jack" || input2 == "Jack"){
row = 2;
}else if(input2 == "SASHA" || input2 == "sasha" || input2 == "Sasha"){
row = 3;
}else{
cout << "Sorry, not a valid input." << endl;
}
}
}
}
| |