Program#2: Vending Machine This vending machine carries only…
Program#2: Vending Machine This vending machine carries only 1 type of drink that costs $1.50 per bottle. The machine can only accept $1 bill, quarter, dime, nickel and penny coins. 1.) Create a user-defined function: Create a C function called convert(). This function accepts one input argument as a single-character (char) type and returns a floating-point value with double precision (double). Utilize switch-case statement within the function convert() to determine the value in dollar of an input character which represents a one-dollar bill or each type of coin as shown in the following table: Type of Cash Input Character Value (dollar) $1 Bill ‘$’ 1.00 Quarter ‘Q’ 0.25 Dime ‘D’ 0.10 Nickel ‘N’ 0.05 Penny ‘P’ 0.01 Other Input Characters: 0.00 Only the five characters: ‘$’, ‘Q’, ‘D’, ‘N’ and ‘P’ are considered as valid inputs. The function convert() should be able to return the corresponding value of the bill or coin to the main function. If the input character is NOT one of the valid characters listed above, the function convert() must return 0.00 2.) In the main function: Create a C program that allows a user to enter a single character from keyboard by using the function: scanf(” %c”, &cash); (notice a space in front of %c) which mimics a scenario of inserting cash into a vending machine. Call the function convert() in the main program to convert the input characters (entered by user) ‘$’, ‘Q’, ‘D’, ‘N’ or ‘P’ into the values of 1.00, 0.25, 0.10, 0.05 or 0.01, respectively. The program should repeatedly display the remaining balance and ask the user to enter a single character as long as there is still a remaining balance. When the remaining balance reaches 0.00 or once the value of cash inserted is greater than the remaining balance, the program should terminate and conclude the amount of change in dollar. Display the remaining balance and the change with 2 decimal places. Hint: Use double precision for the variable: balance Include additional libraries if needed. An example of input/output dialog is shown below: Remaining Balance is $1.50 Insert Cash: $ Remaining Balance is $0.50 Insert Cash: Q Remaining Balance is $0.25 Insert Cash: z Remaining Balance is $0.25 Insert Cash: D Remaining Balance is $0.15 Insert Cash: D Remaining Balance is $0.05 Insert Cash: N Here is your drink! and $0.00 change OR Remaining Balance is $1.50 Insert Cash: P Remaining Balance is $1.49 Insert Cash: Q Remaining Balance is $1.24 Insert Cash: $ Remaining Balance is $0.24 Insert Cash: $ Here is your drink! and $0.76 change Upload your source code (.c file) below: (only .c file will be graded!)
Read DetailsTwo tuning forks of frequency 480 Hz and 486 Hz are struck s…
Two tuning forks of frequency 480 Hz and 486 Hz are struck simultaneously. What is the beat frequency (units: Hz) resulting from the two sound waves? NOTE: Watch correct use of rounding and significant figures Enter numerical answer in proper decimal format, not scientific notation Do not enter units with the answer
Read DetailsThe price of ABC Co’s stock is currently $79.50 and the annu…
The price of ABC Co’s stock is currently $79.50 and the annualized volatility of its log-returns is 57%. The stock does not pay dividends. The risk-free rate is 4.00% per year, continuously compounded.If the price of ABC’s stock increases by $1, approximately how much will the BSOPM price of the three-month, 87.50-strike call change? Only use delta in the approximation.
Read DetailsThere is a container with a rectangular window, the window d…
There is a container with a rectangular window, the window dimensions are 0.101 m by 0.209 m. The container is filled with compressed gas which exerts a total force of 9.41 N perpendicular to the window surface. Calculate the pressure (units: Pa) that the compressed gas exerts on the inside of the window. NOTE: Watch correct use of rounding and significant figures Enter numerical answer in proper decimal format, not scientific notation Do not enter units with the answer
Read Details