Question

In: Computer Science

Assume you are working at Healthy Food company. Your job is to receive food delivery from...

Assume you are working at Healthy Food company. Your job is to receive food delivery from the company suppliers.

You are given a task to receive boxes containing Apple juice. Each box contains a varying number of juice bottles inside.

The delivery person is to bring all the boxes, one at a time, and give you a count of juice bottles in each box. Your job is to write the number of juice bottle in each box. Once all the boxes are delivered you are required to calculate an average of juice bottles per box.

Please write an algorithm to complete this task.

Solutions

Expert Solution

According to the question let us make some assumptions:-

  1. Let the delivery boy delivered all the boxes containing apple juice bottles.
  2. Let the number of apple juice bottles in each box is stored in a one dimensional array of size n, where n denotes the number of boxes delivered by the supplier.

The complete algorithm of the given problem is as follows:-

CountBottles (box[], n)

  1. initialize variables int i, float sum=0.0,avg
  2. for i=1 to number of boxes (n)
    1. print "Box " i "contains" box[i] "bottles"
    2. sum = sum+box[i]
  3. end loop
  4. avg=sum/n
  5. print "average of juice bottles per box is: " avg

The implementation of above algorithm using C code is as follows:-

#include<stdio.h>
void CountBottles(int box[],int n)
{
int i;
float avg,sum=0;
for(i=0;i<n;i++)
{
printf("\nBox %d contains %d bottles",i+1,box[i]);
sum=sum+box[i];
}
avg=sum/n;
printf("\naverage of juice bottles per box is: %f", avg);
}
int main()
{
int box[5]={8,7,9,7,9};
CountBottles(box,5);
return 0;
}

The output of the above code is as follows:-

Box 1 contains 8 bottles
Box 2 contains 7 bottles
Box 3 contains 9 bottles
Box 4 contains 7 bottles
Box 5 contains 9 bottles
average of juice bottles per box is: 8.000000


Related Solutions

You operate a food supply company. Your primary customers are restaurants. You provide delivery services to...
You operate a food supply company. Your primary customers are restaurants. You provide delivery services to select customers. Determine the potential direct and indirect losses that you might incur because of your delivery operations. In terms of risk management.
You are working as exercise physiologist for a company and your job includes tests to measure...
You are working as exercise physiologist for a company and your job includes tests to measure fat oxidation rate (lipid metabolism) during exercise. One individual, who is on a normal diet, did not follow recommendations for fasting and consumed a high fat meal 1-2 hr prior to testing. The fat oxidation response of the individual during prolonged moderate intensity exercise was 30% higher than normal compared to subjects of same age, sex, exercise capacity, and daily diet. What are possible...
Assume you have been working at your first job since college.. You now wish to buy...
Assume you have been working at your first job since college.. You now wish to buy a house for $450,000. You plan to make a 35 percent down payment while financing the rest. Assuming your neighborhood bank offers you a 30-year mortgage with a 4.50% interest rate, what will your monthly payments be? How would your monthly payments change if you increased your down payment to 50 percent?
Suppose your first job after graduating from college is working at a large insurance company. Your...
Suppose your first job after graduating from college is working at a large insurance company. Your boss asks you to analyze the impact self-driving cars will have on revenues from car insurance policies. List four ways self-driving cars could impact the insurance industry. Justify your answers.
Select any engineering company and assume you are an engineering manager working in that company. Your...
Select any engineering company and assume you are an engineering manager working in that company. Your department has been awarded an external grant of $1M to select 1 project of your choice. You have identified 5 mutually exclusive projects to choose from. However, you can only select one and you have decided to select the 1 project by using NPV-based analysis. For this question, you do not have to calculate NPV or show any calculations. (a) List your 5 hypothetical...
     You are a bank regulator working for the Federal Reserve. It is your job to...
     You are a bank regulator working for the Federal Reserve. It is your job to see whether banks are solvent or insolvent, liquid or illiquid. Find the net worth of each bank below and fit them into one of the following four categories. Briefly explain your answers. I.Liquid and Solvent (best). II.Illiquid and solvent (probably needs short-term loans from other banks or from the Fed). III.Liquid but insolvent (should be shut down immediately; could fool people for a while...
You are the owner of a floral delivery company and the fuel for your delivery vehicles...
You are the owner of a floral delivery company and the fuel for your delivery vehicles is one of your biggest expenses. At the beginning of 2014 you introduced a new set of driving instructions to your drivers in the hopes of increasing the average MPG of your vehicles. The gas_example.xlsx file contains a sample of MPG observations for your fleet of vehicles from 2013 and 2014. Now you would like to know if your new driving instructions actually made...
You are working in an oncology floor. Your patient is a previously healthy man aged 40...
You are working in an oncology floor. Your patient is a previously healthy man aged 40 with a new diagnosis of colon cancer. What are some things you will need to implement in his plan of care?
You want to write a simple python program for a food delivery company that asks the...
You want to write a simple python program for a food delivery company that asks the office worker how many drivers they require to deliver their packages to different parts of town. When the user enters the number of drivers, the program will ask how many packages each driver will carry to its destination. It will then calculate the total number of packages and display the result on the screen as below. Sample run: How many drivers do you need?...
Assume you are working on budgeting for the room department of your hotel. Assume the hotel’s...
Assume you are working on budgeting for the room department of your hotel. Assume the hotel’s ‘Room Revenue (Sales)’ was $1,640,000 during 2016. Based on the lodging forecast report, you expect the ‘Room Revenue (Sales)’ to increase by 3.7% next year. Assume the ‘Guest Supplies’ expenses (variable costs) from the room department was $250,000 during 2016. For 2017, this variable cost will remain at the same percentage of the Room Revenue (Sales) as experienced in 2016. Assume the ‘Salaries’ expenses...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT