Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A. read and store command-line input The program will be named \"look-for. It wi

ID: 3745561 • Letter: A

Question

A. read and store command-line input The program will be named "look-for. It will receive input from the command line indicating the locations of the coins to look for, in the following form: prompts look-for coint xe coint y con2.xe In other words, the program will take 6 input values, which are pairs of (x, y) coordinates for three coins hidden in the robot's world 1. Create a point class. The class should have two int data members: x and y. The class shoud have four function members: void print) const, This function prints out the values of the data members x and y .void set( int x, int y ) This function sets the values of the data members x and y. Note that since the function arguments are also called x and y, you should use the this-> pointer to disambiguate between the class's data members and the function arguments. . int getx0 This function returns the value of the x data member int gety0 isnconretums the value of the y data member

Explanation / Answer

#include <iostream>

#include <cstdlib>

using namespace std;

  

int main(int argc, char** argv)

{ int x;

cout << "You have entered " << (argc - 1)  

<< " arguments:" << " ";

if (argc !=2)

{

cout<< " ERROR!!!!! number of arguments should be exactly 2";

return 0;

}

for (int i = 1; i < argc; ++i)

{

cout<<"As you entered ::" << argv[i] << " ";

cout<<"As an integer: "<<atoi(argv[i])<< " ";

x = atoi(argv[i]);

if ((x<0) || (x>9))

{

printf("The range of the arguments is between 0 and 9");

return 0;

}

}

cout<<" "<<"end of the program"<<" ";  

return 0;

}

// instantiating the point object and storing the values of argument is not done

//as you said the 1st part is done by you

//and the code creation of the class should be done there.

//But for a bit of help I can say that you create the object and simply store argv[i] into it and print obj.x and obj.y

//Thank you !!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote