subject

Welcome to the Personal Space Show!! I'm not sure this is the perfect place to put my C++ question, but here it is, nonetheless.

I am supposed to create a program that accepts an unknown number of integer type command line arguments, print the appropriate/corresponding statement from the argument, and print "N: Number not recognized" where N is some integer outside of 1 and 9.

This is my code so far:

/* Personal Space Show from Rick and Morty:
*
* The show is hosted by a man named Phillip Jacobs who is extremely concerned with his personal space
* and takes it very seriously. At times he's paranoid that someone is close to him, even though he is
* alone. After the intro he will direct the camera towards a projector and show slides saying "personal
* space", and telling the viewers to stay out of his personal space. At the end of the show he removes
* his own skin on live TV because he does not care to have it on his personal space.
*/

#include
#include

int main(int argc, char** argv) {

int N = atoi(*argv); //Covert type char* to type int

std::cout << "Welcome to the Personal Space Show!!" << std::endl;

for (N = 0; N < argc; N++) { //Display each command-line argument
std::cout << N << std::endl;
}

switch (N) { //Appropriate statements from Mr. Jacobs
case 1:
std::cout << "One: Personal space";
case 2:
std::cout << "Two: Personal space";
case 3:
std::cout << "Three: Stay out of my personal space";
case 4:
std::cout << "Four: Keep away from my personal space";
case 5:
std::cout << "Five: Get outta dat personal space";
case 6:
std::cout << "Six: Stay away from my personal space";
case 7:
std::cout << "Seven: Keep away from dat personal space";
case 8:
std::cout << "Eight: Personal Space";
case 9:
std::cout << "Nine: Personal space";
}

if (N < 1 || N > 9) {
std::cout << "%d: Number not recognized";
std::cout << N;
}

return 0; //Exit the program
}

Am I on the right track with parsing the command line arguments as well as printing out the correct statement? For some reason, this code keeps failing the auto grader my instructor uses.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 10:20
Suppose there is a relation r(a, b, c) with a b+-tree index with search keys (a, b).1. what is the worst-case cost of finding records satisfying 10 < a < 50 using this index, in terms of the number of records n1, retrieved and the height h of the tree? 2. what is the worst-case cost of finding records satisfying 10 < a < 50 and 5 < b < 10 using this index, in terms of the number of records n2 that satisfy this selection, as well as n1 and h defined above? 3. under what conditions on n1 and n2, would the index be an efficient way of finding records satisfying the condition from part (2)?
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
Perform an online search about the booting process of a computer and list all the steps
Answers: 2
question
Computers and Technology, 24.06.2019 10:30
You're programming an infinite loop. what must you include in your code to prevent crashes? in roblox
Answers: 2
You know the right answer?
Welcome to the Personal Space Show!! I'm not sure this is the perfect place to put my C++ question,...
Questions
question
Mathematics, 28.09.2021 17:30
Questions on the website: 13722363