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

  Create application that has a label and two buttons on form

Think of your favorite joke and identify its setup and punch line. Then, create an application that has a Label and two buttons on a form.

  Compare the two specifications from several points of view

Describe, in both an operational style and a descriptive style, the following problem. Compare the two specifications from several points of view.

  Conducting the forensic investigation

Describe the purpose of several initial reviews being conducted by forensics investigator (e.g., time lines, technical skills, procedures).

  Digital forensics and anti-forensics techniques

Digital Forensics and Anti-Forensics Techniques. The project will be mainly about forensics. The first section will talk about computer forensics, simply is searching to find evidences or recovering deleted data.

  Designing the flow chart

Draw a flowchart describing the following given situations: The data found on employee time cards are keyed onto the hard disk before they are processed by the computer.

  How could the company benefit from e-commerce

How could the company benefit from e-commerce? Should it sell its products (all or some) over the web? Should it use its web site primarily to advertise its products and services?

  Determine the total project duration

Draw by hand the bar chart (Gantt chart) with logic links and draw by hand the activity-on-node (AON) network diagram showing the schedule.

  Program computes and prints the 1000th prime number

Write down a program that computes and prints the 1000th prime number using code blocks c++

  How do you compute the total of all positive inputs

What total is computed when no user input is provided in the algorithm in Section 4.7.1? How do you compute the total of all positive inputs?

  How to implement a stack using an array

How to implement a stack using an array. How to implement a stack using a linear, singly-linked list.

  Define three approaches to organizing programming teams

How does implementing a maintenance change differ from the new system development project.

  Difference between standard and memory-mapped input-output

What is the basic difference between standard I/O and memory-mapped I/O? Identify the programmed I/O technique used by the PIC18F.

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