Explore BrainMass
Share

C+ programing

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

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 October 24, 2018, 5:31 pm ad1c9bdddf
https://brainmass.com/computer-science/logic-design/c-programing-12786

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.

$2.19
See Also This Related BrainMass Solution

C+ programming functions program

Write a C function named change() that accepts a floating point number and the addresses of the integer variables named quarters, dimes, nickels, and pennies. The function should determine the number of quarters, dimes, nickels, and pennies in the number passed to it and write these values directly into respective variables declared in its calling function.

View Full Posting Details