Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Consider the class definition below and answer the questions that follow:

class InsurancePolicy
{
public:
InsurancePolicy();
InsurancePolicy(int pNr, string pHolder, double aRate);
~InsurancePolicy();
void setPolicy(int pNr, string pHolder, double aRate);
int get_pNr()const;
string get_pHolder()const;
double get_aRate()const;
private:
int policyNr;
string policyHolder;
double annualRate;
};

(a) Implement the class InsurancePolicy.
(c) Consider the partial class declaration of an Employee class below:
class Employee: protected Person{
public:
//...
double Rate;
double GetRate() const;
double GetHours() const;
private:
double Hours;
//...
protected:
double Pay() const;
//...
};

double Employee::Pay() const
{
if (DateOfBirth.GetYear() < 1967){
return Hours*Rate;
}
else{
return (Hours*Rate - (Hours*Rate*0.3));
}
}

(iii) Suggest two possible ways of resolving this compilation error.
(c) Consider the partial class declaration of an Employee class below:

class Employee: protected Person{
public:
//...
double Rate;
double GetRate() const;
double GetHours() const;
private:
double Hours;
//...
protected:
double Pay() const;
//...
};

Line 1: cout << E.GetName();
Line 2: cout << E.GetHours();
Line 3: cout << E.Address;
Line 4: cout << E.GetRate();
Line 5: cout << E.Rate;
Line 6: cout << E.Pay();

(ii) Explain why the following implementation of function Pay()would result in a
compilation error.
(c) Consider the partial class declaration of an Employee class below:
class Employee: protected Person{
public:

//...
double Rate;
double GetRate() const;
double GetHours() const;
private:
double Hours;
//...
protected:
double Pay() const;
//...
};

(i) The code fragment below (extracted from a main() function) has three invalid
statements. Write down the line numbers of the invalid statements and explain
why each of these statements is invalid. E is an instance of an Employee
object.

Line 1: cout << E.GetName();
Line 2: cout << E.GetHours();
Line 3: cout << E.Address;
Line 4: cout << E.GetRate();
Line 5: cout << E.Rate;
Line 6: cout << E.Pay();
Consider the following class definitions and answer the questions that follow:

class Date {
public:
Date(int day, int month, int year);
int GetYear() const;
private:
int Day;
int Month;
int Year;
};
class Person{
public:
Person(const string &name, const string &address, const
Date &date);
string GetAddress() const;
string GetName() const;
private:
string Name;
string Address;
Date DateOfBirth;
};
class Customer{
public:
Customer(const string &name, const string &address,
int day, int month, int year,double creditlimit);
void IncreaseLimit(double amount);
string GetName() const;
string GetAddress() const;
void SetBalance(double balance);
double GetBalance() const;
private:
string Name;
string Address;
int DayOfBirth;
int MonthOfBirth;
int YearOfBirth;
double CreditLimit;
double BalanceDue;
};

(b) Implement the constructor for the derived Customer class.
Consider the following class definitions and answer the questions that follow:

class Date {
public:
Date(int day, int month, int year);
int GetYear() const;
private:
int Day;
int Month;
int Year;
};
class Person{
public:
Person(const string &name, const string &address, const
Date &date);
string GetAddress() const;
string GetName() const;
private:
string Name;
string Address;
Date DateOfBirth;
};
class Customer{
public:
Customer(const string &name, const string &address,
int day, int month, int year,double creditlimit);
void IncreaseLimit(double amount);
string GetName() const;
string GetAddress() const;
void SetBalance(double balance);
double GetBalance() const;
private:
string Name;
string Address;
int DayOfBirth;
int MonthOfBirth;
int YearOfBirth;
double CreditLimit;
double BalanceDue;
};

(a) Provide an improved declaration for the Customer class that exploits the
principles of reusability. Provide the interface only.
Overload the +, - and * operators for objects of class Pairs in question 4, as
member functions. Also define the class Pairs as an ADT that uses separate files
for the interface and the implementation. Use separate compilation and the same
program as in question 4 to test these member functions.
The program below contains an incomplete recursive function raised_to_power().
The function returns the value of the first parameter number of type float raised to
the value of the second parameter power of type int for all values of power greater
than or equal to 0.

1. #include <iostream>
2. using namespace std;
3. float raised_to_power( )
4. {
5. if (power < 0)
6. {
7. cout << "\nError - can't raise to a negative power\n";
8. exit(1);
9. }
10. else if ( )
11. return ( );
12. else
13. return (number * raised_to_power(number, power - 1));
14. }
15. main()
16.
17. float answer = raised_to_power(4.0,3);
18. cout << answer;
19. return 0;
20.}

(a) Complete the function header in line 3.
(b) Using the fact that any value raised to the power of 0 is 1, complete the base
case in line 10 and 11.
(c) Why do we need a base case in a recursive function?
(d) What is the purpose of the general case?
The placement session has begun in a college. There is N number of students standing outside an interview room in a line. It is given that the person who goes first has higher chances of selection.
Each student has a number associated with them representing their problem-solving capability. The higher the capability the higher the chances of selection. Now every student wants to know the number of students ahead of him with higher problem-solving capability.
Input: 6(number of students) {4 , 9 , 5 , 3 , 2 , 10}
Output: {0 , 0 , 1 , 3 , 4 , 0}
1. Debug(find and correct errors) and run the Python script file Lab X,
2. Analyze the output and interpret what the script is about or does[reading comments may help]
import threading
import time
def myThread():
print("Thread {} starting".format(threading.currentThread().getName()))
time.sleep(10)
print("Thread {} ending".format(threading.currentThread().getName()))
for i in range(4):

"""In the preceding code,a function myThread is defined. Within this function,
we utilize the threading.currentThread().getName()
in order to retrieve the current thread’s moniker, a
nd print this out both when we start our thread’s execution, and when it ends.
We then go on to start a for loop, and create four thread objects that take in
the name parameter, which we define as “Thread-” + str(i), as well as
the myThread function as the target of that thread’s execution.
We then, finally, go on to print out all the active threads currently running.
"""
LATEST TUTORIALS
APPROVED BY CLIENTS