Program 1
Write the money collection interface for the vending machine.Your program should tell the user the price of the item and then the user will enter the amount of money that they are paying (this simulates them actually inserting cash).If the money collected is less than the price, print an appropriate message (such as: “Insufficient funds, no sale!”) and then the program should ask the user if he or she wants to try. If the user entersyes, the program will ask to enter the amount, else it will exit the program.If enough money is collected, determine the amount to return to the customer. If the change due is not zero, tell the user how much change they will receive.Next, print a message (such as “Thank you – enjoy your drink!”) and end the program normally. Note, your program should be able to handle all amounts of money (not just multiples of dollars but also cents such as $1.25).Also, you may assume that the user is only entering a number and not the $ (though the $ could be part of your prompt). Hint: Check how to do floating-point comparisons!
Program2.Write a program to determine the drink size based on the letter the user enters.Print a message to the user giving the various drink size options and then prompt the user for the drink size.The user can enter an ‘s’ or ‘S’ for small, an ‘m’ or ‘M’ for medium, and an ‘l’ or ‘L’ for large.Depending on which size the user requests, print a message such as: “You have ordered a (small, medium, large) drink.” In addition to displaying the size ordered, also record a price multiplier.The price multiplier for a small is 1, for a medium is 2, and for a large is 3.If the user does not enter a valid character, print an error message (such as “Error: Invalid drink size”) and loop in the program asking again to re-enter the size. You should use nested if‐then‐else statements for this problem.After the nested if‐then‐else statements, print the value of the price multiplier to ensure that the correct value was recorded (the price multiplier will be used in program 4).Hint: use the logical OR expression in your comparisons.
Program 3. Write a program that displays the various coffee drinks your vending machine offers along with the option number for each drink. Beside each option include the price (you can set the cost for the small, the costs for medium should be 2 times the cost of the small, and the cost of the large should be 3 times the cost of the small). These are the options:
1.Espresso (Small $1.75 , Medium $3.50, Large $5.25)
2.Americano (Small $1.75 , Medium $3.50, Large $5.25)
3.Café au Lait (Small $1.75 , Medium $3.50, Large $5.25)
4.Latte (Small $1.75 , Medium $3.50, Large $5.25)
For example: Then prompt the user for their drink selection and enter their selection. Record the cost of the small drink into a variable that will be used to compute the amount due (to be used in program 4). Display a message such as “You selected Latte ”. If the user does not enter a valid option, print an error message, and have them re-enter the option. You should use a conditional statement for this problem. To check that you have recorded the amount due properly, after the statement, display the amount due for the small size of the drink selected.
Program 4.Write a program that combines programs 1 through 3 into one vending machine user interface program. First, welcome the user and display the drink options, prompt the user for their drink selection, enter their selection, and record the amount due for a small (program 3).
Next, display the size options, prompt the user for the size, enter their size selection, and record the price multiplier (program 2). Based on the size entered, your program should adjust the amount due. Next, display the amount due, prompt the user for their payment, enter their payment, and determine the amount of change to return (program 1).
Ask the user if they want another drink, if the response is yes, the program will display the menu again and goes through the process. If the user enters no, the program should exit.
NOTE: If in any case, the user enters an invalid option or size of the drink, your program should prompt an invalid option or invalid size and loop through the program.
Note: Any additional computations or control should also be included. In program 4 you should remove any unnecessary print statements used in programs 1 through 3 that do not display useful information to the user.