Explore BrainMass

C+ programing

Write a program that includes a function PICNIC() that will accept a floating-point number TOTAL and the addresses of the interger variables HOTDOGS, HAMBURGERS,SALAD,PICKLES. The passed floating-point number represents the TOTAL amount of money to be spent on food. The function is to determine the quantity of HOTDOGS, HAMBURGERS,SALAD,PICKLES that can be purchaced, writing these values directly into the respective variables declared in the calling function.

This function will be called from the main program and when it returns to main, it will print out the values of HOTDOGS, HAMBURGERS,SALAD,PICKLES.
Our favorite foods are in this order:
1- hotdogs 1.00$ each
2- hamburgers .50$ each
3- salad .25$ each
4- pickles .01$ each

Example: if I enter the total amount of money of 3.78$, i can bring the following items to my picnic: 3 hotdogs, 1 hamburger, 1 salad, 3 pickles.

© BrainMass Inc. brainmass.com June 22, 2018, 12:32 pm ad1c9bdddf

Solution Preview

In this type of program, use of weights to clearly state which item is favored much makes the program more versatile. For example, if I have $0.75, then I may buy 1 hamburger and 1 ...

Solution Summary

C+ programing is modeled.