Create an object of this class whose member var initialized

Assignment Help Computer Engineering
Reference no: EM132194475

Write a C++ program A3p2.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.

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 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 a value on the command line argument (that is, argv[1]) and then call the play member function to output the sequence of desired integers.

Reference no: EM132194475

Questions Cloud

Print the appropriate messages if the user enters wrong : Write a C++ program which accepts username and password from user and then print on the screen whether the user is authenticated or not.
Create new vectors - one to hold the odd integers : Create 2 new vectors - one to hold the odd integers and one to hold the even integers. Display the contents of both vectors.
How much distance is transverse by the instant : It takes 10.0 s for a Ferrari to accelerate from 0 miles per hour to 60 miles per hour. How much distance is transverse by the instant that the Ferrari.
Reported occurrence of identity theft : Identify the measures you can employ to prevent identity theft and discuss how you would respond to a reported occurrence of identity theft.
Create an object of this class whose member var initialized : The class should contain a protected int variable var, which is initialized with an integer value between 1 and 50 in a constructor.
How csr is important to a business from an ethical viewpoint : How doe the stakeholder theory explain how CSR is important to a business from an ethical viewpoint?.
What angle does vector make with the positive x axis : The x and y components of a displacement vector are -3.00 m and +4.00 m, respectively. What angle does this vector make with the positive x axis?
How csr is important to a business from an ethical viewpoint : How doe the stakeholder theory explain how CSR is important to a business from an ethical viewpoint?.
Write a program to handle student data in an input file : Write a program to handle student data in an input file. Each line in the file represents information for one student.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd