Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You may be asked to create a function to solve each of the tasks given below. Fo

ID: 3601566 • Letter: Y

Question

You may be asked to create a function to solve each of the tasks given below. For each task state the purpose of the function, what the function needs complete the task (input), what the function will send back to the function call (output), and the process (algorithm) needed to complete the task. Do not write any C++ code, but clearly specify what needs to be passed to the function, output will be sent back to the function call, and algorithm. Also state which parameters should be passed by value and which should be passed by reference. 1. Design a function for the scenario given below. The function should not have any input statements in it You are working for a bottling company. Bottles are placed into different types of packaging. Six (6) bottles are put into a six-pack. Four (4) six-packs are combined to form a case. Thirty (30) cases are wrapped together to form a pallet for shipping. You are to create a function that will determine the number of pallets, cases, six- packs and single bottles are created from the total number of produced during a shift. The function should be designed to minimize the number of each packaging type and number of bottles not in a package. The algorithm should contain no more than 7 arithmetic operators. The number of each type of packaging should be sent back to the function call For example if 1559 bottles were produced during a shift that would correspond to 2 pallets, 4 cases, 3 six-packs, and 5 single bottles 2. Design a function that will solve the quadratic formula for determining roots -b1b2-4ac 2a The function should send back to the function call the two roots and if they are real or imaginary If the quantity (b- - 4ac) is less than zero, the roots will be imaginary and you should use the absolute value of (b2 - 4ac) to determine the root values. 3. Design function that will read a series of numbers from a file and send back to the function call the largest 3 values in the file without storing the values in an array and/or sorting the values.

Explanation / Answer

1)

We have to pass the total bottles as value,pallet,sixPacks,cases,singles as references to the function.

Inside the function we have to do these calculations to get pallet,sixPacks,cases,singles

totalBottles=1559

pallet = totalBottles /30;

rem= totalBottles %30;

sixPacks= (rem)/6;

rem=rem%6;

cases=(rem)/4;

singles=rem%4;

Then the calling function will get the values

______________

2)

We have to pass the coefficients a,b,c as values and root1 and root2 as references.

Then the function should find the absolute value of the discriminate .So that even the value is negative we will get two roots.

abs(pow(b, 2)-4*a*c)

root1=((-b+part1)/(2*a));
root2=((-b-part1)/(2*a));

As we passed root1 and root2 as references the calling function will get thse values.

_________________

3)

We have to pass the reference input stream as ( ifstream& dataIn) and largest variable as reference to the function as parameters.

Then the function will open the file and read the three values from the file and stored In the variables.

Then do some comparisons

If(x>y && x>z)

{

largest=x;

}

else If(y>x && y>z)

{

largest=y;

}

else

{

largest=z;

}

The we will calling function will get the largest value

___________Thank YOu

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote