***Program must compile under Ubuntu!
(35 pts) Write a C++ program A4p3.cpp with a class that is a derived class of your class from problem 2. Add a private intmember variable var2 to this class. Initialize the member variables var and var2 with values between 1 and 50 using a constructor that takes two integer parameters. Add a public member function called getsp that should print out the sum and product of var and var2. In your main function, create an object of this class, initialize its members var and var2 through constructor with the first two command line arguments to your program (i.e., argv[1] and argv[2]) and then call the play and getsp member functions on the object. A sample run can look like the following. Submit source code A4p3.cpp and you don’t need to submit a screen shot. Please do NOT just submit A4p3.cpp because it seems to include all functionality of A4p2.cpp. You need to submit two separate program source files.
[kwang@computer][~/temp]$./A4p3 6 8
Iterated integer sequence for 6 is:
6 3 5 8 4 2 1
Length of the sequence: 7
Sum of 6 and 8 is 14. Product of 6 and 8 is 48.
#include<iostream>
#include<cstdlib>
using namespace std;
class Sequence{
public:
int var;
Sequence(){
}
Sequence(int k){
var = k;
}
void play(){
int count = 1;
int temp = var;
cout<<temp<<" ";
while(temp != 1){
if(temp%2==0){
temp = temp/2;
}else{
temp = (3*temp + 1)/2;
}
cout<<temp <<" ";
++count;
}
cout<<"\nLength of the sequence: "<<count<<endl;
}
};
class NewSequence: public Sequence{
public:
int var2;
NewSequence(int a, int b){
Sequence();
var = a;
var2 = b;
cout<<var << " "<<var2<<endl;
}
void getsp(){
cout<<"Sum of "<<var<<" and "<<var2<<" is "<<var +var2<<" ."<<endl;
cout<<"Product of "<<var<<" and "<<var2<<" is "<<var*var2<<" ."<<endl;
}
};
int main(int argc, char ** argv)
{
int val;
if(argc < 3){
cout << "Invalid number of argument\n";
exit(0);
}
int n1 = atoi(argv[1]);
if(n1 < 1 || n1 > 50){
cout<<"Value not within range 1-50";
exit(0);
}
int n2 = atoi(argv[2]);
if(n2 < 1 || n2 > 50){
cout<<"Value not within range 1-50";
exit(0);
}
NewSequence seq(n1,n2);
seq.play();
seq.getsp();
return 0;
}
======================================================================================
SEE OUTPUT

PLEASE COMMENT if there is any concern.
=============================
***Program must compile under Ubuntu! (35 pts) Write a C++ program A4p3.cpp with a class that...
**Program must compile under Ubuntu! (35 pts) Write a C++ program A4p2.cpp with a class of your own design. The class should contain a protected int member 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 playthat should print out a sequence of integers as a result of iteratively applying a math function f to the member variable var...
Write the interface (.h file) of a class Accumulator containing:A data member named sum of type integer.A constructor accepting an integer parameter.A function named getSum that accepts no parameters and returns an integer.A function named add that accepts an integer parameter and returns no value.class Accumulator{int sum;Accumulator(int);int getSum ();void add (int);};Write the implementation (.cpp file) of the Accumulator class of the previous exercise. The full specification of the class is:An data member named sum of type integer.A constructor that accepts...
C++ Program 1a. Purpose Practice the creation and use of a Class 1b. Procedure Write a class named Car that has the following member variables: year. An int that holds the car’s model year. make. A string object that holds the make of the car. speed. An int that holds the car’s current speed. In addition, the class should have the following member functions. Constructor. The constructor should accept the car’s year and make as arguments and assign these values...
Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...
C++ program Create a class Time having data members HH, MM, SS of type integer. Write a C++ program to do the following: 1. Use a Constructor to initialize HH, MM, SS to 0. 2. Create two Objects of this class and read the values of HH, MM, SS from the user for both objects (Using proper member functions). 3. Use a binary + operator to add these two objects created (Store & display result using separate object). 4. Use...
Please show it in C++. Thank you!
Problem Definition Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial baiance and uses it to initialize the data member. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money...
Project_10_base_files.zipMakefile (2).txtProject_10_main 1.JPGProject_10_main 2.JPGProject_10_main 3.JPGProject_10 h.JPGProject_10 cpp.JPGAny C++ technique covered in Chapters 1 through 12is allowedexcept for global variablesYou are not allowed to use any global variables.If necessary, global constants may be used.Project 10DescriptionFor this project a Date class(specifiedin the file Project_10.h) will be constructed and all function definitions will be written in the file Project_10.cpp. A makefileis provided to compile this project. The file Project_10_main.cppcontainsthe main functionthat is used to run the program.On Canvas, download the files Project_10.h, Project_10_main.cpp...
// P13_2.cpp - This program adds money of two different people #include<iostream> #include<cstdlib> using namespace std; class AltMoney { public: AltMoney(); AltMoney(int d, int c); friend void add(AltMoney m1, AltMoney m2, AltMoney& sum); void display_money( ); private: int dollars; int cents; }; void read_money(int& d, int& c); int main( ) { int d, c; AltMoney m1, m2, sum; sum = AltMoney(0,0); read_money(d, c); m1 = AltMoney(d,c); cout...
1. Write a program which have a class named as “Student”, while the data members of the class are,a. char name[10],b. int age;c. string color;d. string gender;e. double cgpa;and the member function “print()”, is just to display these information.1. You need to create 3 objects of the “Student” class.2. Initialize one object by the default constructor having some static values.3. Initialize the second object by the parameterized constructor, while you need to pass values for initialization.4. Initialize the third object...
In C++, Step 1: Implement the Student Class and write a simple main() driver program to instantiate several objects of this class, populate each object, and display the information for each object. The defintion of the student class should be written in an individual header (i.e. student.h) file and the implementation of the methods of the student class should be written in a corresponding source (i.e. student.cpp) file. Student class - The name of the class should be Student. -...