Questions: 11 448

Answers by our Experts: 10 707

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

3. Write a C++ recursive function that takes a string and reverse the string.


4. Write a C++ recursive function that takes an array of words and returns an array

that contains all the words capitalized.


5. Write a linear search C++ program that searches for a number in a two

dimensional array.


6. What is each on the following functions going to achieve:

a)

int fun(int x, int y)

{

if (x == 0)

return y;

else

return fun(x - 1, x + y);

}


b)

int fun(int a, int t)

{

if (a == 0)

return t;

t = (t * 10) + (a % 10);

return fun(a / 10, t);

}


Consider the process of taking the average of a list of N (real) numbers. The list will be contained in an array, X, of real numbers. The numbers will be referenced as X[0], X[1], X[2], ..., X[N-1].

a) Prove that the process of taking the average of a list of N real numbers is recursive.

Hint: Use function polymorphism.


b) As a result of a) above or otherwise, write the corresponding polymorphic and

recursive C++ function that computes the average of a list of N numbers.


Consider a list of (real) numbers, X, of length N. Squaring each number in the list is a recursive process. Prove this by writing a polymorphic and recursive C++ function


template <class Type>

Type * square (Type * X, long int N)

{

// C++ code

}


which recursively squares each element in X and returns that list (i.e. X with

elements squared).


A company has both part time and full time employees. The details of full-time employees include name department contacts basic pay and part time employees Inherit some properties of full time employees calculate their basic pay and basic details

Write a c++ program that

Has a class named Queue for storing integers. In a queue, the elements are retrieved in a FIFO fashion.The class contains:


■ An int[] data fieldnamed elements that stores the int values in the queue.


■ A data field named size that stores the number of elements inthe queue.


■ A constructor that createsa Queue object with defaultcapacity 8 .


■ The method enqueue(int v) that adds v into the queue.


■ The method dequeue() that removes and returns theelement from the queue.


■ The method empty() that returns true if the queue isempty.


■ The method getSize() that returns the size of the queue.


Implement the class with the initial arraysize set to 8. The array size will be doubled once the number of the elementsexceeds the size. After an element is removed from the beginning of thearray,you need to shift all elements in the array one position the

left. Writea test program that adds 20 numbers from 1 to 20 into the queue and removesthese numbers and displays them.


Write a function that takes 4 coordinates of the Rectangle and a point P as a parameter. Your function should be able to tell whether P lies inside the Rectangle, On the Rectangle, or Outside rectangle. Sample Input:

P1 0 0

P2 2 0

P3 2 2

P4 0 2

P 1 1

Output: P lies inside Square


10.Write a function which takes as input 4 points and tell whether these points


are the coordinates of Square, Rhombus, Rectangle, Parallelogram or


Quadrilateral. NOTE: Make separate functions for each case checking whether


its square / rhombus / rectangle / parallelogram. i-e (isSquare, isRhombus,


isRectangle, isParallelogram)


Sample Input:


P1 0 0


P2 1 0


P3 1 1


P4 0 1


Output: It’s a square


Write a function which takes as parameter 3 points and tell whether these



points are the coordinates of isosceles or equilateral or right angled or scalene



triangle. NOTE “Make separate functions as isEquilateral, isRightAngled and



so on... ”.



Sample Input: P1 0 0



P2 1 0



P3 1 1



Sample Output: Right Angle Triangle

Write a c++ program that computes the monthly net pay of the employee for a steel factory. The input for this program is the hourly rate of pay, the number of regular and the overtime hour work. The tax-deductible rate is 20%. You need first to calculate the gross pay, which is the sum of the wages earned from regular hours and overtime hours, the overtime is paid at 1.5 times the regular rate. Then you subtract the tax from the gross pay to get the net pay of the employee.


You are living off-campus and drive your car to ODU campus everyday of a week. You wonder how many mileages you travel in a week (just to campus and back home) and how much you need to pay for the gas. You log your travel mileage every day during a week (just to campus and back home). This information has been saved in an input file called “mileage.txt”.

Design an algorithm and write a C++ program to do the following:

  • Output the mileage for each day.
  • Prompt user to enter the price for one-gallon gas.
  • Calculate and output the total cost of your travel in the week. Your car's Miles per Gallon (MPG) is 35.
  • Save the output in a file named “cost.txt”.
LATEST TUTORIALS
APPROVED BY CLIENTS