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, 21.06.2019 23:00
The animal classthis class represents a an animal residing at a zoo. it has a weight (in pounds),height (in inches), a name, and a color. the methods in the class include constructors,getters, and a tostring. you will finish the implementation of these methods. referto the code documentation.1.getters: you will need to implement getter methods. these get a value (froma member variable) in the animal class. you will make a getter method toreturn each variable (weight, height, name, color). reference getname if youare having issues.2.tostring: you will need to finish the tostring method. this returns a stringcontaining information about an animal. the output string should be of theformat: ” (name) , a ( color )â’colored animal . ( weight ) pounds , ( height ) inches .\n”the height and weight are formatted to 1 decimal place. recall from lab 1how to format strings neatly using string. see the reference sectionfor more about string.format.
Answers: 2
question
Computers and Technology, 22.06.2019 18:00
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
question
Computers and Technology, 22.06.2019 21:50
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
question
Computers and Technology, 22.06.2019 23:00
Is an attack that relies on guessing the isns of tcp packets
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
English, 29.10.2021 22:30
question
Mathematics, 29.10.2021 22:30
question
Mathematics, 29.10.2021 22:40
question
Mathematics, 29.10.2021 22:40