Question: I need help in writing C # program and we are using Visual studio. Please I need proper comments so i can easily understand the

I need help in writing C # program and we are using Visual studio. Please I need proper comments so i can easily understand the code and can do it by myself.

please follow the steps also in the Instructions.

First comment should be the NAME.

I need help in writing C # program and we are using

Visual studio. Please I need proper comments so i can easily understandthe code and can do it by myself. please follow the stepsalso in the Instructions. First comment should be the NAME. You are

making a program that emulates purchasing a soda from a vending machine,

You are making a program that emulates purchasing a soda from a vending machine, using coins Your user can enter 5 for a nickel, 10 for a dime, and 25 for a quarter (Explain these choices to the user). For simplicity we'll assume that they won't enter any other number besides 5, 10 or 25. The base price of a soda is $1.00, but we'll set a random price prior to each soda purchase. We will vary the price by 0, 5, 10 or 15 cents in either direction from $1.00 The user will enter the name of the soda. That can be anything. Steps to do the program Start by defining a base price for every soda. Make an integer variable and set it equal to 100 Hit enter a few times to make room for inserting lines of code. Also use blank lines to improve code readability. We need a random number generator. Have it make numbers from -5 to 5. Then multiply that random number by 5 and assign it to an integer variable that holds the soda price variance. Make an integer variable for the soda price. It is equal to the base price of all sodas plus the price variance that you just made. Now each new soda has a price between 75 and 125, in five cent increments. Welcome the user to your machine and inform them of the acceptable coins to use. Get their soda type from them and put that in a string variable. Tell them the cost of their type of soda. Your output should look like mine Make a loop that is always true. Inside that loop: Have the user insert a coin (we will assume a valid value). Make an integer variable to hold the accumulated payments. Set it to zero at the top of the program. Then here, in the loop, set it equal to itself plus the coin just deposited Remember to convert the coin to an integer so you can do math with it. o Make another integer variable to hold the changing balance due on the soda. Set it to zero at the top of the program. Then here, in the loop, set it equal to the price of this soda (not the base price of all soda) minus the current amount of accumulated payments Still in the loop: oMake an IF statement. If the balance due of the soda is greater than zero tell the user how much they still owe. Then use a continue statement to return to the top of the loop. o Make an ELSE IF statement. If the balance due of the soda is less than zero inform the user how much they have been refunded. That value will be negative, which will look weird. Change it in the output by putting Math.Abs around the variable Like Console.Writeline(S"You get Math.Abs(the balance due) cents back.") Make an ELSE statement. Write one blank line. Add a break statement. That's it for the stuff inside the loop. Now tell the user to enjoy their soda. And add a ReadKey so the program pauses. Refund example: Welcome to the soda machine. You can enter values of 5, 1e, or 25 in payment hat type of sode would you like? Diet Coke The current price of Diet Coke is 110 cents. Insert a coin: 25 ou still owe 85 cents. Insert a coin: 10 You still owe 75 cents. Insert a coin: S You still owe 7e cents. Insert a coin: 25 You still owe 45 cents. Insert a coin: 25 ou still owe 20 cents. Insert a coin: 25 ou have been refunded 5 cents. Enjoy your Diet Coke! Exact Payment example Welcome to the soda machine. You can enter values of 5, 18, or 25 in payment at type of sode would you like? Sprite The current price of Sprite is 110 cents Insert a coin: 10 You stil1 owe 180 cents. Insert a coin: 1 You still owe 90 cents. Insert a coin: 25 You stil1 owe 65 cents. Insert a coin: 25 You still owe 40 cents. Insert a coin: 25 You still owe 15 cents. Insert a coin: 10 You still owe 5 cents. Insert a coin: Enjoy your Sprite

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!