Please help finish this problem I need to write a c++ program using class Point
ID: 3633712 • Letter: P
Question
Please help finish this problemI need to write a c++ program using class Point that if you input xval and yval 20 30 your offset values will be 22 32 Max value is 50.
compiler output should be as follows
Set xval and yval 20 30
Offset values 22 32
Maximum value is 50
press any key to continue....
Here is what the code should look like
#include <cstdlib>
#include <iostream>
using namespace std;
class Point
{
public:
void SetPt(int, int);
void Offsetpt(int, int);
int MaxArray(int[], int);
private
int xval, yval;
int max_x;
};
int main(int argc, char *argv[])
{
Point pt;
pt.Setpt(20,30); // object
int a[4]={20,30,40,50};
cout<<pt.MaxArray(a,4);
///
///
///
///
}
void Point::SetPt(int x, int y)
{
xaval=x;
//fill in
}
system("PAUSE");
return EXIT_SUCCESS;
}
Explanation / Answer
#include #include #include //using namespace std; //create class point class point{ public: //Define methods void setpt(int,int); void offsetpt(int,int); int MaxArray(int[],int); private: //Declare variables int xval,yval; int max_x; };//end class //Main method int main(int argc, char *argv[]) { point pt;//create object clrscr(); //call methods pt.setpt(20,30); pt.offsetpt(22,32); //Define array a and assign values int a[4]={20,30,40,50}; /Display output coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.