Chat with us, powered by LiveChat 1.Write A C++ Program A4p2.Cpp With A Class Of Your Own Design. The Class Should Contain A Protected Int Variable Var, Which Is Initialized With An Integer Value Between 1 And 50 In A Constructo | Writedemy

1.Write A C++ Program A4p2.Cpp With A Class Of Your Own Design. The Class Should Contain A Protected Int Variable Var, Which Is Initialized With An Integer Value Between 1 And 50 In A Constructo

1.Write A C++ Program A4p2.Cpp With A Class Of Your Own Design. The Class Should Contain A Protected Int Variable Var, Which Is Initialized With An Integer Value Between 1 And 50 In A Constructo

1.Write a C++ program A4p2.cpp with a class of your own design. The class should contain a protected int variable var, which is initialized with an integer value between 1 and 50 in a constructor that takes an integer parameter. The class should contain a public member function called play that should print out a sequence of integers as a result of iteratively applying a math function f to the integer var. The function f is defined as f(x)=3x+1 if x is odd and f(x)=x/2 if x is even. Stop the iteration when the value 1 is reached. (Example: When var is 6, the play function’s output sequence should be 6,3,10,5,16,8,4,2,1.) In your main function create an object of this class whose member var should be initialized with the first command line argument (that is, argv[1]) and then call the play member function to output the sequence of desired integers. You can check whether the supplied first command line argument is an integer between 1 and 50 in the main function.

2. Write a C++ program A4p3.cpp with a class that is a derived class of the class in problem 2. Add a private int member var2 to this class. Initialize the member variables var and var2 with a value between 1 and 50 using a constructor that takes two integer parameters. Add a public member function called getgcd that should print out the greatest common divisor of var and var2. (You can refer to gcd.c in Folio’s sample codes directory for how to compute the greatest common divisor of two integers.) In your main function, create an object of this class, initialize the members var and var2 with the first two command line arguments (that is, argv[1] and argv[2]) and then call the play and getgcd functions.

3. supply a makefile to compile the program.

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order