Questions
c++ LINEAR SEARCH ARRAYS OF OBJECTS Use the Item class defined in question #12. 1. (3...

c++

LINEAR SEARCH ARRAYS OF OBJECTS

Use the Item class defined in question #12.

1. (3 pts) Declare an array of 1024 Item objects. Assuming the array is now sorted by Value (price per item * quantity).

2. Write a function (with both declaration/prototype (3 pts) and definition (6 pts) ) that takes an array of Item objects, an integer as array size and two references to integers that represents the start_index and end_index of Item object elements whose Values are 50.0.

The function's implementation should be:

  • initialize both start_index and end_index parameters to -1.
  • perform a linear search to identify the range of all elements whose Values are 50.0. Note: since the array is sorted your searching must stop as soon as some Item exceeds 50.0.
  • If there is only one item is found both start_index and end_index must be the same. Otherwise set start_index and end_index to indicate the range of elements

An example of such array of Items will be the below:

index                   0               1               2             3           4              5           6           7               8              9          ........

Value         21.4      23.3       50.0      50.0      50.0       67.5      88.0       88.3      95.2      141.5    ....... (Note that the array is sorted)

In this example your function must assign 2 to start_index and 4 to end_index.

#12

This question has two parts:

Part 1: Define an Item class with the following specifications:

NOTE: you must declare and define the class separately. Include the definitions of constructors/destructor and member functions in class declaration will result in 50% point deduction.

  • Constructors: (MUST USE member initializer syntax) (2 pts)
    • default constructor (set description to "Unknown", quantity to 0, value to 0.0)
    • non-default constructor (3 parameters with the same names as member data' names)
  • Destructor: output <description> <quantity> and <price per item>   (1 pts)
  • Member data (2 pts): description, quantity (how many), price per item. Do not initialize member data at declaration - it must be done in constructors)
  • static data (1 pts) : company name (initialized to "Foothill Merchandise")). Must be constant string and not accessible from outside of the class.
  • public static function (1 pts): to return company name
  • public member functions (3 pts):
    • accessors/mutators: to save your exam time only provide accessor/mutator for "price per item" member
    • Increment: take a positive integer as its only parameter and add it to quantity. If the parameter is negative simply return.
    • Value: return total value of the item (quantity * price per item)

NOTE: The class definition must follow Google naming convention for class name, member data names and member function names (do not use camelCase convention)

Part 2: (5 pts)

Instantiate two Item objects: one using the default constructor and the other using the non-default constructor (description: "Toys", quantity: 100, price per item: 29.95).

Invoke the company name (static data).

Set the price per item of the default object to the non-default object's price per item.

Output the Value of the non-default object.

Increment the default-object's quantity to 9999.

In: Computer Science

DNA transposons and retrotransposons are similar: they both have poly-A segments at one end. both can...

DNA transposons and retrotransposons are similar:

they both have poly-A segments at one end.

both can encode an enzyme required for mobilization.

transposition results in movement of the original transposon to a different place in the genome, losing the previous spot.

during transposition, both go through an RNA form that is copied back into DNA.

In: Biology

Suppose that a country’s inflation rate increases sharply. Explain what happens to inflation tax on the...

Suppose that a country’s inflation rate increases sharply. Explain what happens to inflation tax on the holders of money? .  Can you think of anyway in which holders of savings accounts are hurt by the increases in the inflation Rate?

In: Economics

The following is the balance sheet of Korver Supply Company at December 31, 2020 (prior year)....

The following is the balance sheet of Korver Supply Company at December 31, 2020 (prior year). KORVER SUPPLY COMPANY Balance Sheet At December 31, 2020 Assets Cash $120,000 Accounts receivable 300,000 Inventory 200,000 Furniture and fixtures (net)  150,000 Total assets $770,000 Liabilities and Shareholders’ Equity Accounts payable (for merchandise) $190,000 Notes payable 200,000 Interest payable 6,000 Common stock 100,000 Retained earnings  274,000 Total liabilities and shareholders’ equity $770,000 Transactions during 2021 (current year) were as follows: 1. Sales to customers on account $800,000 2. Cash collected from customers 780,000 3. Purchase of merchandise on account 550,000 4. Cash payment to suppliers 560,000 5. Cost of merchandise sold 500,000 6. Cash paid for operating expenses 160,000 7. Cash paid for interest on notes 12,000 Additional Information: The notes payable are dated June 30, 2020, and are due on June 30, 2022. Interest at 6% is payable annually on June 30. Depreciation on the furniture and fixtures for 2021 is $20,000. The furniture and fixtures originally cost $300,000.

Required: Prepare a classified balance sheet at December 31, 2021, by updating ending balances from 2020 for transactions during 2021 and the additional information. The cost of furniture and fixtures and their accumulated depreciation are shown separately.

In: Accounting

Hey, how do I create a function which receives one argument (string). The function would count...

Hey, how do I create a function which receives one argument (string). The function would count and return the number of alphanumeric characters found in that string. function('abc 5} =+;d 9') // returns 6 in JavaScript?

In: Computer Science

Calculate ΔrxnS, ΔrxnH, and ΔrxnG at 298Kfor the reaction below: 2 C3H6 (g) ----------------->   C2H4 (g)    ...

Calculate ΔrxnS, ΔrxnH, and ΔrxnG at 298Kfor the reaction below:

2 C3H6 (g) ----------------->   C2H4 (g)     +     C4H8 (g)

In: Chemistry

(python please) The Cache Directory (Hash Table):The class Cache()is the data structure you will use to...

(python please)

The Cache Directory (Hash Table):The class Cache()is the data structure you will use to store the three other caches (L1, L2, L3). It stores anarray of 3 CacheLists, which are the linked list implementations of the cache (which will be explained later). Each CacheList has been already initialized to a size of 200. Do not change this. There are 3 functions you must implement yourself:

•def hashFunc(self, contentHeader)oThis function determines which cache level your content should go in. Create a hash function that sums the ASCII values of each content header, takes the modulus of that sum with the size of the Cache hash table, and accordingly assigns an index for that content –corresponding to the L1, L2, or L3 cache. So, for example, let’sassume the header “Content-Type: 2”sumsto an ASCII value of 1334. 1334% 3 = 2. So, that content would go in the L3cache. You should notice a very obvious pattern in which contentheaders correspond to which caches. The hash function should be used by your insert and retrieveContent functions.

•def insert(self, content, evictionPolicy)oOnce a content object is created, call the cache directory’s insert function to insert it into the proper cache. This function should call the linked list’s implementation of the insert function to actually insert into the cache itself. The eviction policywill be a string –either ‘lru’or ‘mru’. These eviction policies will be explained later. oThis function should return a message including the attributes of the content object inserted into the cache. This is shown in the doctests.

•def retrieveContent(self, content)oThis function should take a content object, determine which level it is in, and then return the object if it is in the cache at that level. If not, it should return a message indicating that it was not found. This is known as a “cache miss”. Accordingly, finding content in a cache is known as a “cache hit”. The doctests show the format of the return statements.

In: Computer Science

I have to write a lab report on "Measuring the value of g". For the theory...

I have to write a lab report on "Measuring the value of g". For the theory section, I have to predict my theoretical value for "g " and its uncertainty. Explain how did I arrive to those numbers (do not quote someone else's value for "g").

Does anyone have an idea of how can I do this? Thanks a lot.

In: Physics

How have we evolved over time to rely upon “non-paper” money to drive economies around the...

How have we evolved over time to rely upon “non-paper” money to drive economies around the world?

In: Economics

Acme Company Balance Sheet As of January 5, 2019 (amounts in thousands) Cash 9,100                            &nbsp

Acme Company Balance Sheet As of January 5, 2019 (amounts in thousands)

Cash 9,100                                              Accounts Payable 1,900

Accounts Receivable 4,400                        Debt 2,400

Inventory 4,800                                         Other Liabilities 600

Property Plant & Equipment 15,600            Total Liabilities 4,900

Other Assets 2,600                                  Paid-In Capital 6,900

                                                               Retained Earnings 24,700

                                                              Total Equity 31,600

Total Assets 36,500                                 Total Liabilities & Equity 36,500

Update the balance sheet above to reflect the transactions below, which occur on January 6, 2019

1. Sell product for $25,000 with historical cost of $20,000

2. Sell product for $30,000 with historical cost of $24,000

3. Sell product for $40,000 with historical cost of $32,000

What is the final amount in Retained Earnings?

Please specify your answer in the same units as the balance sheet.

In: Accounting

Ahmed’s income statement is as follows: Sales (10,000 units) $40,000 Less variable costs (24,000) Contribution margin...

Ahmed’s income statement is as follows:

Sales (10,000 units)

$40,000

Less variable costs

(24,000)

Contribution margin

$16,000

Less fixed costs

(12,000)

Operating income

$ 4,000

  1. If Sales increase by $10,000, what is the new operating income?
  2. Calculate the Break-even point in units for Herman.
  3. Herman wants to earn operating income of $20,000. What amount of sales dollars will he need in to accomplish this goal?
  4. Herman wants to earn net income (after taxes) of $35,000 and his tax rate is 30%. What amount of sales dollars will he need to accomplish this goal?

In: Accounting

Alice and Bob are experimenting with CSMA using a W2 Walsh table. Alice uses the code...

Alice and Bob are experimenting with CSMA using a W2 Walsh table. Alice uses the code [+1, +1] and Bob uses the code [+1, −1]. Assume that they simultaneously send a hexadecimal digit to each other. Alice sends (6)16 and Bob sends (B)16. Show how they can detect what the other person has sent.

In: Computer Science

What is the change in enthalpy (in kJ) under standard conditions when 200.18 g of sodium...

What is the change in enthalpy (in kJ) under standard conditions when 200.18 g of sodium sulfate dissolves in water?

In: Chemistry

I am tasked with creating a Java application that used 2 synchronized threads to calculate monthly...

I am tasked with creating a Java application that used 2 synchronized threads to calculate monthly interest and update the account balance

This is the parameters for reference to the code. Create a class AccountSavings. The class has two instance variables: a double variable to keep annual interest rate and a double variable to keep savings balance. The annual interest rate is 5.3 and savings balance is $100.
• Create a method to calculate monthly interest. • Create a method to run two threads. Use anonymous classes to create these threads. The first thread calls the monthly interest calculation method 12 times, and then displays the savings balance (the balance in 12th month). After that, this thread sleeps 5 seconds. The second thread calls the monthly interest calculation method 12 times, and then displays the savings balance (the balance in 12th month). Before the main thread ends, these two threads must be completed. • Add your main method into the same class and test your threads. After these two threads are executed, the savings balance must remain same

I am getting an error when calling monthlyInterest method inside my runThread method. non-static method monthlyInterest() cannot be referenced from a static context and I cant seem to figure out how to fix the issue.


import static java.lang.Thread.sleep;

class AccountSavings {

    double annualInterest=5.3;
    double savings=100.00;
  
  

    public void monthlyInterest(){
    double monthlyRate;
    monthlyRate = annualInterest/12;
    double balance = 0;
    balance+=savings*monthlyRate;
    }
  
    public synchronized static void runThread(){
  
        Thread t1;
        t1 = new Thread(){
            AccountSavings accountSavings= new AccountSavings();
            @Override
            public void run(){
                for(int i=1;i<13;i++){
                    System.out.println("Balance after " + i + "month: " + monthlyInterest());
                }
                try{sleep(5000);}
                catch(InterruptedException e){e.printStackTrace();}
            }
        };
    Thread t2= new Thread(){
  
    AccountSavings accountSavings=new AccountSavings();
    @Override
    public void run(){
  
        for(int i=1;i<13;i++){
        System.out.println("Balance after " + i + " month: " + monthlyInterest(balance));
        }
        try{sleep(5000);}
        catch(InterruptedException e){e.printStackTrace();}  
    }
    };
    t1.start();
    t2.start();
  
    }

    public static void main(String[] args){
  
        runThread();
  
    }

}

In: Computer Science

i drop a 1 kg book from a height of 1m, what is the velocity of...

i drop a 1 kg book from a height of 1m, what is the velocity of the book as it hits the floors 1m below if it loses 2j energy through air resistence.

In: Physics