Using only <iostream>, implement a dynamic array. You are to build a class called MyDynamicArray. Your...

Using only <iostream>, implement a dynamic array. You are to build a class called MyDynamicArray. Your dynamic array class should manage the storage of an array that can grow and shrink. The public methods of your class should be the following:

MyDynamicArray(); Default Constructor. The array should be of size 2.

MyDynamicArray(int s); For this constructor the array should be of size s.

~MyDynamicArray();Destructor for the class.

int& operator[](int i); Traditional [] operator. Should print a message if i is out of bounds and return a reference to a zero value.

void add(int v); increases the size of the array by 1 and stores v there.

void del(); reduces the size of the array by 1.

int length(); returns the length of the array.

int clear(); Frees any space currently used and starts over with an array of size 2.

Here is a sample main.cpp file:
#include <iostream>
using namespace std;
#include "MyDynamicArray.cpp"
int main() {
MyDynamicArray x;
for (int i=0; i<100; i++){
x.add(i);
}
int sum = 0;
for (int i=0; i<x.length(); i++){
sum+=x[i];
}
cout << "The sum is : " << sum << endl;
for (int i=0; i<95; i++)
x.del();
x[60] = 27;

MyDynamicArray y(10);
for (int i=0; i<y.length(); i++) y[i] = i*i;
for (int i=0; i<200; i++){
y.add(i);
}
sum = 0;
for (int i=0; i<y.length(); i++){
sum+=y[i];
}
cout << "The sum is : " << sum << endl;
for (int i=0; i<195; i++)
y.del();
y[60] = 27;
for (int i=0; i<200; i++){
y.add(i);
}
sum = 0;
for (int i=0; i<y.length(); i++){
sum+=y[i];
}
cout << "The sum is : " << sum << endl;

}
Here is the output from the main.cpp above :
Doubling to : 4
Doubling to : 8
Doubling to : 16
Doubling to : 32
Doubling to : 64
Doubling to : 128
The sum is : 4950
Reducing to : 64
Reducing to : 32
Reducing to : 16
Out of bounds reference : 60
Doubling to : 20
Doubling to : 40
Doubling to : 80
Doubling to : 160
Doubling to : 320
The sum is : 20185
Reducing to : 160
Reducing to : 80
Reducing to : 40
Out of bounds reference : 60
Doubling to : 80
Doubling to : 160
Doubling to : 320
The sum is : 20195

In: Computer Science

Using Appendix 4 for ∆Hf ° and ΔS˚, which of the following reactions is spontaneous: (5.a)...

Using Appendix 4 for ∆Hf ° and ΔS˚, which of the following reactions is spontaneous:

(5.a) 2 H2S(g) + 3 O2(g) → 2 H2O(g) + 2 SO2(g)

(5.b) SO2(g) + H2O2(ℓ) → H2SO4(ℓ)

(5.c) S(g) + O2(g) → SO2(g)

You must determine whether a given reaction (i) is exothermic or endothermic, (ii) has a positive or negative entropy, and (iii) if a given reaction is spontaneous only at low temperature or only at high temperature, or at all temperatures.

In: Chemistry

This year Burchard Company sold 29,000 units of its only product for $19.20 per unit. Manufacturing...

This year Burchard Company sold 29,000 units of its only product for $19.20 per unit. Manufacturing and selling the product required $114,000 of fixed manufacturing costs and $174,000 of fixed selling and administrative costs. Its per unit variable costs follow. Material $ 3.40 Direct labor (paid on the basis of completed units) 2.40 Variable overhead costs 0.34 Variable selling and administrative costs 0.14 Next year the company will use new material, which will reduce material costs by 70% and direct labor costs by 30% and will not affect product quality or marketability. Management is considering an increase in the unit selling price to reduce the number of units sold because the factory’s output is nearing its annual output capacity of 34,000 units. Two plans are being considered. Under plan 1, the company will keep the selling price at the current level and sell the same volume as last year. This plan will increase income because of the reduced costs from using the new material. Under plan 2, the company will increase the selling price by 30%. This plan will decrease unit sales volume by 15%. Under both plans 1 and 2, the total fixed costs and the variable costs per unit for overhead and for selling and administrative costs will remain the same. Required: 1. Compute the break-even point in dollar sales for both (a) plan 1 and (b) plan 2. (Round "per unit answers" and "CM ratio" percentage answer to 2 decimal places.)

In: Accounting

Charges q, q, and -q are placed on the x-axis at x = 0, x =...

Charges q, q, and -q are placed on the x-axis at x = 0, x = 2 m, and x = 4 m, respectively. At which of the following points does the electric field have the greatest magnitude?

a x = 1 m

b x = 3 m

c x = 5 m

d The electric field has the same magnitude at all three positions.

In: Physics

1. Discuss the implications of facility location decisions on a supply chain. 2. Discuss the critical...

1. Discuss the implications of facility location decisions on a supply chain.

2. Discuss the critical factors influencing facility location.

In: Operations Management

1. An aluminum ion Al3+ is placed on the positive x-axis a distance of 0.80 m...

1. An aluminum ion Al3+ is placed on the positive x-axis a distance of 0.80 m from the origin. A -15 nC charge is on the positive x-axis a distance of 0.50 m from the origin. A +32 nC charge is on the negative x-axis a distance of 1.00 m from the origin.

a) Find the net force on the -15 nC charge. _____________________

b) Find the net force on the aluminum ion. _____________________

c) Find the electric field at the origin. _____________________

In: Physics

Single Plantwide and Multiple Production Department Factory Overhead Rate Methods and Product Cost Distortion The management...

Single Plantwide and Multiple Production Department Factory Overhead Rate Methods and Product Cost Distortion

The management of Firebolt Industries Inc. manufactures gasoline and diesel engines through two production departments, Fabrication and Assembly. Management needs accurate product cost information in order to guide product strategy. Presently, the company uses a single plantwide factory overhead rate for allocating factory overhead to the two products. However, management is considering the multiple production department factory overhead rate method. The following factory overhead was budgeted for Firebolt:

Fabrication Department factory overhead $774,000
Assembly Department factory overhead 344,000
Total $1,118,000

Direct labor hours were estimated as follows:

Fabrication Department 4,300 hours
Assembly Department 4,300
Total 8,600 hours

In addition, the direct labor hours (dlh) used to produce a unit of each product in each department were determined from engineering records, as follows:

Production Departments Gasoline Engine Diesel Engine
Fabrication Department 1.30 dlh 3.00 dlh
Assembly Department 2.70 1.00
Direct labor hours per unit 4.00 dlh 4.00 dlh

a. Determine the per-unit factory overhead allocated to the gasoline and diesel engines under the single plantwide factory overhead rate method, using direct labor hours as the activity base.

Gasoline engine $ per unit
Diesel engine $ per unit

b. Determine the per-unit factory overhead allocated to the gasoline and diesel engines under the multiple production department factory overhead rate method, using direct labor hours as the activity base for each department.

Gasoline engine $ per unit
Diesel engine $ per unit

c. Recommend to management a product costing approach, based on your analyses in (a) and (b).

Management should select the ___________ factory overhead rate method of allocating overhead costs. The __________ factory overhead rate method indicates that both products have the same factory overhead per unit. Each product uses the direct labor hours __________. Thus, the __________ rate method avoids the cost distortions by accounting for the overhead __________.

In: Accounting

How would you describe Structure of Management Information (SMI)? Also justify, how it is useful for...

How would you describe Structure of Management Information (SMI)? Also justify, how it is useful for a managed object?

In: Computer Science

Give your own example of how microevolution can happen (include the 4 mechanisms in your answer)....

Give your own example of how microevolution can happen (include the 4 mechanisms in your answer). What is an adaptation and how is it different from a mutation?

In: Biology

Explain how the defect in the CFTR ion channel results in the disease. Think about osmosis...

Explain how the defect in the CFTR ion channel results in the disease. Think about osmosis and how this process is important in maintaining the proper water balance in cells

In: Biology

Introduction to IS & IT IT101 What problems are caused by data redundancy? Can data redundancies...

Introduction to IS & IT

IT101

What problems are caused by data redundancy? Can data redundancies be completely eliminated when the database approach is used? Justify your answer in your own words.

In: Computer Science

You will write several classes for this program in Java. The name of all classes for...

You will write several classes for this program in Java. The name of all classes for this program will start with y2y3.

Concepts to be applied :

Classes and objects, inheritance, polymorphism

Assignment:

An electronic store, named carrefoure, services many customers. The customers’ orders for electronics are delivered. Carrefoure bills their customers once each month. At the end of each month, the regional store manager requests a report of all customers. In this program, you will develop the inheritance hierarchy for the program. The set of classes developed for the program will be used for future assignments.

            The superclass for this assignment will represent a Customer of Carrefoure.

            Some of the Customers will be tax exempt customers (will not pay taxes on the) but others will be non tax exempt customers (will pay tax on the bill balance at a given percent).

            The fields are the instance variables of the classes in the hierarchy:

  • Customer name (String)
  • Customer ID (numeric integer)

o            phone number (numeric integer)

o            Amount paid (numeric)

o            Reason for tax exemption (only for tax-exempt-customers) – String, for example: education, non-profit, etc

o            Tax percent (only for non-tax-exempt customers) – decimal, for example: .08 for 8%, .075 for 7.5%

The customers served by careffoure are of two types: tax-exempt or non-tax-exempt. The tax-exempt customer will have an instance field to store the reason for the tax exemptions: education, non-profit, government, other (String). The non-tax exempt customers, will have an instance field to store the percent of tax that the customer will pay (numeric) on the bill balance.

From the information provided, write a solution that includes the following:

A suitable inheritance hierarchy which represents the customers serviced by the office supply company. There should be 3 classes for this program. I suggest a Customer class and two suitable subclasses. The tax percent field only applies for a non-tax exempt customer. The reason for tax exemption only applies to a tax exempt customer.  

            For all classes include the following:

o            Instance variables

o            Constructors

o            Accessor and mutator methods

o            Suitable toString() methods

Write a class y2y3 which does the following in the main method:

            Create two objects for customers who are tax exempt and create two objects for customers who are non-tax exempt.

            Print all the information about the objects as shown below:

Output:

Non tax exempt customers:

1 PWC   $750   18002500830     0.08%   $60

2 E&Y   $970    18003409845     0.08%   $77.6

Tax exempt customers:

3 AHS   $255.50     19734508345             Non-profit

4 PIO      $500        18002708855           Non-profit

In: Computer Science

Use python. DO NOT use pres existing libraries. Suppose there exists a text file called "expressions.txt"....

Use python. DO NOT use pres existing libraries. Suppose there exists a text file called "expressions.txt". This file contains simple arithmetic expressions written in infix notation. Using the Stack class, write code to implement the Shunting Yard Algorithm to generate postfix expressions. Each expression in expressions.txt is written on a single line. Moreover, each expression contains only numbers comprising a single digit. Each token is separated by whitespace. Write each postfix expression generated to a file "answers.txt". Only consider the operations +, -, /, *, and ^.

In: Computer Science

I am trying to make a robot move (theoretically), some of my code does not work...

I am trying to make a robot move (theoretically), some of my code does not work in python. I am getting some errors. How can I fix it?

This is my code:

#!/usr/bin/env python.3

import time
import sys
import random


#Provide a Menu for the User
def main():
print("To control LED press 1")
print("To drive press 2")
print("To change motor speed press 3")
print("To control the Servo press 4")
while True:
option = int(input("Enter the numbers 1, 2, 3, or 4:"))
if option == 1:
LED()

elif option == 2:
Drive()

elif option == 3:
Speed()

elif option == 4:
Servo()

else:
print("Wrong letter or number, please try again.")


#Options for LED
def LED():
print("To turn led on press 5")
print("To turn led off press 6")
print("To exit press 0")
while True:
option = int(input("Enter numbers 5 or 6:"))
if option == 5:
led_on(0)

  
elif option == 6:
led_off(0)

elif option == 0:
main()

#Options for Drive control
def Drive():
print("To move forward press W")
print("To move right press D")
print("To turn left press A")
print("To move backwards press S")
print("To increase speed press T")
print("To decrease speed press G")
print("To stop press X")
print("To exit press Z")

while True:
option = input("Enter letters W , D, A, S, T, G, X, or Z:")
if option == "W":
fwd()
time.sleep(.3)

elif option == "D":
right()
time.sleep(.3)

elif option == "A":
left()
time.sleep(.3)
  
elif option == "S":
backwards()
time.sleep(.3)
  
elif option == "T":
increase()
time.sleep(.3)
  
elif option == "G":
decrease()
time.sleep(.3)

elif option == "X":
stop()

elif option == "Z":
main()


#Options for Motor speed functions
def Speed():
print("Set Speed press 7")
print("To exit press 0")
while true:
option = int(input("Enter number 7:"))
if option == 7:
Set_speed()

elif option == 0:
main()



#Options to control Servo
def Servo():
print("To move servo to the right press 8")
print("To move servo to the left press 9")
print("To move servo forward press 10")
print("To return to the menu press 0")
while True:
option = int(input("Enter numbers 8, 9, or 10:"))
if option == 8:
enable_servo()
servo(0)
time.sleep(1)
disable_servo()

elif option == 9:
enable_servo()
servo(180)
time.sleep(1)
disable_servo()

elif option == 10:
enable_servo()
servo(90)
time.sleep(1)
disable_servo()

elif option == 0:
main()

main()

In: Computer Science

Project: Assume you are a senior Engineer in a Ghanaian private multi-disciplinary construction company which have...

Project:

Assume you are a senior Engineer in a Ghanaian private multi-disciplinary construction company which have intended to expand its business operation to Cameroun and Democratic Republic of Congo. Design and build staff bungalows for an expatriate firm. The company has acquired a plot of land to be developed for the senior staff of ten in each country.

QUESTION:

Planning stage: Provide analysis on how you would go about networking in these countries before establishing or settling.

NB: I want answer only for the question on planning stage

In: Civil Engineering