GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

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 Details

Write a formula for a linear function f whose graph satisfie…

Write a formula for a linear function f whose graph satisfies the conditions.Slope: – ; y-intercept:

Read Details

State whether the given function is linear and constant, lin…

State whether the given function is linear and constant, linear but not constant, or nonlinear.f(x) = -3x + 7

Read Details

Two 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 Details

The 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 Details

There 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

Consider a pipe that flows through the ground floor and up t…

Consider a pipe that flows through the ground floor and up to the second floor of house. 4 °C fresh water is pumped at a speed of 0.50 m/s through a 5.0 cm diameter pipe at the ground floor, under a pressure of 2.5 atm. What will be the pressure in a 4.0 cm diameter pipe at the second floor 6.0 m above. 

Read Details

An object is attached to the end of an ideal spring which ha…

An object is attached to the end of an ideal spring which has a spring constant of 105 N/m and is extended to 2.8 cm from it equilibrium position. What is the magnitude of the force (units: N) exerted by the spring? 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

A simple pendulum consists of a small 50.0 g ball hanging on…

A simple pendulum consists of a small 50.0 g ball hanging on a 0.800 m long thread of negligible mass. The ball is pulled a small angle to one side and released. Find the period (units: Hz) of oscillation for this simple pendulum. 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

An option trader creates a delta-hedged covered call (or “bu…

An option trader creates a delta-hedged covered call (or “buy-write”) in order to short 400 call options on a stock with a spot price of $200. The stock’s log-return has a volatility of 40 percent per year. The trader chooses to short the OOM calls with a strike price of $220 and five days until expiration (assuming 252 trading days in a year). The appropriate risk-free rate is 4 percent per year. If the price of the underlying were to immediately fall by $20, approximately what gain or loss would the trader experience? Use delta and gamma to calculate the approximation. Enter your answer as a number of dollars, rounded to the nearest $0.0001. Enter gains as positive amounts and losses as negative amounts.

Read Details

Posts pagination

Newer posts 1 … 37,346 37,347 37,348 37,349 37,350 … 77,564 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top