c++ programing.
Objectives
Define a class called Person with private members name of type string, and money of integer type. The class has the public member functions set(), getMoney(), print(), and a parameterized constructor with default values.
Define a class called Patient with private data members name of type string, durationOfTreatment, and TreatmentCost of type integer. The class has the public member functions set(), getCost(), getDuration(), print(), and a parameterized constructor with default values.
Define a class called Doctor that publicly inherits the class Person and has the private members numberOfPatients,totalCost, list[] (an array of type Patient), and calculateTotalCost(). The class has the public member functions set(), print(), and a parameterized constructor with default values.
Implement all member functions, enforcing the principle of least privileged.
The following driver produces the given sample input / output.
int main()
{
Doctor Hakeem;
Hakeem.set("Ali Omar", 3000, 3);
Hakeem.print();
return 0;
}
Sample input / output:
Enter the name, duration, and cost of treatment number 1: Allergies 23 150
Enter the name, duration, and cost of treatment number 2: Bronchiectasis 15 280
Enter the name, duration, and cost of treatment number 3: Gallstones 10 50
Ali Omar has 3000 dirham and treated the following patients:
Allergies was treated for 23 minutes, at a cost 150 dirham per minute
Bronchiectasis was treated for 15 minutes, at a cost 280 dirham per minute
Gallstones was treated for 10 minutes, at a cost 50 dirham per minute
The total cost of the 3 patients is 8150 dirham
The overall total of money is 11150 dirham
In: Computer Science
Given the relation R = {(n, m) | n, m ∈ ℤ, n ≥ m}. Which of the following statements about R is correct?
|
R is not a partial order because it is not antisymmetric |
|
|
R is not a partial order because it is not reflexive |
|
|
R is a partial order |
|
|
R is not a partial order because it is not transitive |
In: Computer Science
Complete the following recursively defined functions.
Base case ?(0)=3
Recursive case ?(?) = 3?(? − 1) + 7 for n ≥ 1.
?(1) = ______
f(2) = _______
f(3) = ______
f(4) = ______
Base case ?(0)=1, ?(1)=2
Recursive case ?(?) = ?(? − 1)?(? − 2) for n ≥ 2.
g(2) = ______
g(3) = ______
g(4) = ______
g(5) = ______
In: Computer Science
Using C++
If you have 2 plants (A and B) with the hight of plant A is less than the hight of plant B. However, the hight of plant A is growing faster than the hight of plant B (the hight is measured in centimetres and the hight growth rate is matured daily). Write a program that prompts the user to enter the hight and the hight growth rate of each plant. The program should check that the hight of plant A is less than the hight of plant B and that the growth rate of plant A is higher than the growth rate of plant B and it should not work otherwise. The program outputs after how many days the hight of plant A will be greater than or equal to the hight of plant B, and the hight of both plants at that time.
A sample input and output is as follows:
First Run:
Enter the hight of plan A (in centimetres): 26
Enter the hight growth rate of plant A: 0.04 Enter the hight of plant B: 25
Enter the hight growth rate of plant B: 0.02
Plant A hight should be less than plant B hight and plant A growth rate should be higher than plant B growth rate.
Second Run:
Enter the hight of plan A (in centimetres): 22
Enter the hight growth rate of plant A: 0.04
Enter the hight of plant B: 25
Enter the hight growth rate of plant B: 0.02
The hight of plant A will be greater than or equal to the hight of plant B after 7 days.
Plant A hight will become 28.9505
Plant B hight will become 28.7171
In: Computer Science
Justify the statement “Spam detection is perhaps the classic example of pattern recognition”.
In: Computer Science
Question1: Define a class Human that contains: - The data fields "first name" and "last name" - A constructor that sets the first and last name to the instance variables. Create also a no-argument constructor - A getName() method which prints the first and last name Define the class Student which inherits Human and contains: - Private data field "mark" of type integer and a constructor which calls the superclass constructor Define the class Worker which inherits Human and contains: - Private date fields "wage" and "hours worked", and a constructor which calls the superclass constructor - A setWageInfo() method which sets the wage information to the instance variables - A calculateWage() method which calculates a worker’s salary based on wage and hours worked Write a program called HumanTest that instantiates two Human objects (one using the noargument constructor and another using the constructor with parameters). Call the method getName(). Create a Student object which calls the getName() method. Create a Worker object which calls the methods getName(), setWageInfo(), and claculateWage().
In: Computer Science
Question 2: Design a class named Square that contains data fields side and surfaceArea, and a method called getSurfaceArea(). Create a child class named Cube. Cube contains a getCubeSurfaceArea() method that calculates the cube surface area. Write a program called DemoSquare that instantiates a Square object and a Cube object and displays the surface areas of the objects. Use the methods created to set the value of the side, and return the surface area. Hint: square area= side*side, Cube surface area= 6 × side2
In: Computer Science
Design an algorithm that minimises Ccmp, the number of comparisons of two books’ labels in the alphabetical order, and Cmov, the number of book movements (one movement is counted whenever a book is moved from one location to another) in the worst case. Suppose there arenbooks on the main shelf, which haveal ready been sorted in an ascending alphabetical order. The m newly arrived books are carried into the library on a portable shelf.
a) Scenario 1: The newly arrived books have also been sorted in an ascending alphabetical order and you are allowed to use a temporary shelf of an infinite capacity. Design an algorithm (description + pseudo code) for the robot to arrange the new books onto themain shelf using Ccmp=Θ(n+m) label comparisons and Cmov=Θ(n+m) book movements in the worst case. Explain why your algorithm has the stated worst case complexity (ignoring the constant and choosing the dominant term in your analysis).
Algorithm ArrangingBooksScenario1(A,B,C,n,m)
//A,B, and C represent the arrays of book labels for the main, the portable, and the temporary shelves
//COMPLETE WITH YOUR PSEUDO CODE HERE
b) Scenario 2: There is no temporary shelf to use in the library and the number of newly arrived books,m, is a small constant compared ton, for instance,m=10. Design an algorithm (description + pseudo code) for the robot to arrange the new books onto the main shelf using Ccmp=Θ(log(n)) label comparisonsin the worst case. What is the number of book movements Cmov incurred in the worst-case of your algorithm and why?
Algorithm ArrangingBooksScenario2(A,B,n,m)
// A and B represent the arrays of book labels for the main and the portable shelves
//COMPLETE WITH YOUR PSEUDO CODE HERE
P/s: I have already posted this question, but haven't received a useful idea for it. So, please help me with a useful idea and more detailed pseudocode.
In: Computer Science
Discuss how you would network a university with two campuses, taking into account the various sections of that campus (computer labs, health clinic, offices, security post, etc), discussing the choice of technologies, devices, topology/topologies, network types, protocols and anything else you would use and justifying your choices
In: Computer Science
For the prelab assignment, you may not use the if statement nor may you use the if/else statement. You are to write a program that calculates factorials from 1 up to and including a maximum number given by the user. Because factorials get large quickly, use long unsigned int as the type for the number entered by the user as well as the factorials you are calculating. If the user enters a 0, print an error message. Then ask if the user wishes to continue the program or quit.
In: Computer Science
Suggest one or more analysis pattern for the following application domains: PLEASE DO NOT HAND WRITE THE ANSWER!! PLEASE ANSWER ALL PARTS OF THE QUESTION!!
A) Accounting Software
B) Email software
C) Internet Browsers
D) Word - Processing software
E) Website creation software
In: Computer Science
Q#1: Take a real-world scenario and Implement it in
C++ program. Your program
should consist of the following:
1. Constructors
2. Pointers
3. Private and Public keywords
4. Reference by return
5. Const keyword
6. Passing Object as argument
In: Computer Science
IN PYTHON 3 LANGUAGE
Define a recursive function named immutify; it is passed any data structure that contains int, str, tuple, list, set, frozenset, and dict values (including nested versions of any of these data structures as an argument). It returns an immutable equivalent data structure (one that could be used for values in a set or keys in a dict). The types int, str, and frozenset are already immutable. Convert a set to a frozenset; convert all the values in a tuple to be their immutable equivalents, in the same order); convert a list to a tuple (with immutable equivalents of its values, in the same order); convert a dict to tuple of 2-tuples (see the association tuple in question 2) but here with the 2-tuples sorted by the dict’s keys. If immutify ever encounters a value of another type (e.g., float) it should raise a TypeError exception.
The following call (with many mutable data structures)
Example 1:
immutify( {'b' : [1,2], 'a' : {'ab': {1,2}, 'aa' : (1,2)}} )
returns the immutable data structure
(('a', (('aa', (1, 2)), ('ab', frozenset({1, 2})))), ('b', (1, 2)))
Example 2:
immutify( [{1,2}, {3,frozenset([4,5])}, {6,7}])
Returns
(frozenset({1, 2}), frozenset({3, frozenset({4, 5})}),
frozenset({6, 7}))
In: Computer Science
Please use R studio
Dataset: IBM HR Analytics Employee Attrition & Performance dataset (you can download the dataset from kaggle)
|
Name |
Description |
|
ATTRITION |
Employee leaving the company (0=no, 1=yes) |
|
BUSINESS TRAVEL |
(1=No Travel, 2=Travel Frequently, 3=Tavel Rarely) |
|
DEPARTMENT |
(1=HR, 2=R&D, 3=Sales) |
|
EDUCATION FIELD |
(1=HR, 2=LIFE SCIENCES, 3=MARKETING, 4=MEDICAL SCIENCES, 5=OTHERS, 6= TEHCNICAL) |
|
GENDER |
(1=FEMALE, 0=MALE) |
|
JOB ROLE |
(1=HC REP, 2=HR, 3=LAB TECHNICIAN, 4=MANAGER, 5= MANAGING DIRECTOR, 6= REASEARCH DIRECTOR, 7= RESEARCH SCIENTIST, 8=SALES EXECUTIEVE, 9= SALES REPRESENTATIVE) |
|
MARITAL STATUS |
(1=DIVORCED, 2=MARRIED, 3=SINGLE) |
|
OVER 18 |
(1=YES, 2=NO) |
|
OVERTIME |
(0=NO, 1=YES) |
The Variable Attrition is what we plan to use as our dependent variable. The variable contains a Yes if they stay with IBM and ‘No’ if they do not. We need to create this into a binary dummy variable with 0 if they do not stay with IBM (Attrition = ‘No’) and 1 if they do stay with IBM (Attrition = ‘Yes’). This will also need to be done to the variable Gender and OverTime. Gender we can assign “Male” to zero and “Female” to one. For OverTime we will assign 0 for “No” and 1 for “Yes”.
Create Pivot tables instead of correlation matrixes for categorical variables and do the data analysis.
For data analysis:
Describe the data using the techniques above (e.g. “We can see in this scatter plot that there is a positive correlation between the number of hours in which the patient exercised per week and his/her weight loss.”). About one page without the images.
Based on these observations, draw some insights. (e.g. “We believe the patient is burning calories when exercising, thus contributing to the loss of weight”). About one page.
State actionable experiments based upon your insights. (e.g. “We will use multiple regression that includes hours exercised as an explanatory variable to model weight loss. We expect…”)
In: Computer Science
Considering the following different search trees, binary search trees, AVL trees, red-black trees, and others. Compare their advantages and disadvantages, running times, etc
In: Computer Science