Create a coke machine program in c++

Assignment Help C/C++ Programming
Reference no: EM13936983

Create a coke machine program in C++ using if statements and loops.

Think about how a coke machine works and what the code would look like.

We will start by having the users insert their money. Since they can not physically insert the money, we will just ask them how much they wish to insert and we will keep track of how much money they have inserted.

The money insertion will be handled in a Loop. For example, before they start, their total inserted is $0. Let us say that a drink costs $1.00. If they say that they are inserting $0.25 then we will add $0.25 to $0 and tell them to please insert $0.75 more. Then we will ask them how much they are inserting. If they say $0.25, then we add $0.25 to the $0.25 that they have already inserted giving them $0.50. Once they have inserted $1.00, we can give them their drink options. If they have not entered at least $1.00, we will continue to loop so that they can insert more.

Once they have entered enough money, we will ask then what drink they would like. It could be something like this.

Please make your selection
1 = Coke
2 = Pepsi
3 = Dr Pepper

Put the entire main function in a loop so once the transaction is completed, the program will ask if you would like to purchase another drink (y/n). If you choose y for yes, the program will loop again, starting over with $0.00 entered and begin asking the user to enter money. If the user chooses n for no, the loop will exit and an output statement will tell the user what all they have purchased. For example:

You have purchased 1 Coke and 2 Dr. Peppers.

In order to do this, create an array of drinks that have been purchased.

Something like:

Drinks
Coke 0
Pepsi 0
Dr. Pepper 0
Sprite 0
Orange 0

Each time they purchase an item, add one to the number purchased. So, if they purchase a Pepsi, then the number in spot 1 (remember the first spot in an array is 0) would be that number + 1.

Once they have made all of their choices, give them a message saying something like:

You have purchased 2 Cokes.
You have purchased 3 Pepsies.
You have purchased 1 Dr. Pepper.
You have purchased 0 Sprites
You have purchased 9 Orange.

The above numbers will change based on how many of each drink has been purchased.

Reference no: EM13936983

Questions Cloud

Explain components of our immune system : Explain the components of our immune system involved in allergic reactions, and how does treatment of allergies manage to control them?
Complete a financial analysis and assessment of a company : It will require you to complete a full financial analysis and assessment of a company listed on the Australian Stock Exchange. You may select any company listed on the Australian Stock Exchange EXCEPT Telstra and TOLL
Analysis of an organisations brand management and promotion : Description: Analysis of an organisations brand management and promotion • Weighting: 15.00% • Instructions: Students will develop a critical analysis on an organisations use of brand management and promotion.
Calculate the total monthly budget : ASSIGNMENT: You are to create a new blank Excel workbook saving the workbook with the file name as lastname_firstinitial_statement. Organize and enter the information below into a Microsoft 2013 Excel worksheet. Calculate the Total Monthly Budget,..
Create a coke machine program in c++ : We will start by having the users insert their money. Since they can not physically insert the money, we will just ask them how much they wish to insert and we will keep track of how much money they have inserted.
Innovative marketing promotions campaign : Devise an ‘innovative' marketing promotions campaign for Healthy Care's new Magnesium massage oil range for the January to May period 2016.
Discuss small populations and extinction vortices : Discuss reasons why plant and animal populations may differ in their susceptibility to extinction, discuss three reasons that exotic species are often able to drive native species to extinction.
Explain the steps for building a rudimentary management : Explain the steps for building a rudimentary management system.
What eye colors will the offspring have : Eye color in fruit flies (Drosophila) is a sex-linked trait where the dominant allele coes for red eyes and the recessive codes for white eyes. If you cross a white-eyed female with a red-eyed male, what eye colors will the offspring have?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Mark the following statements as valid or invalid

Mark the following statements as valid or invalid. If a statement is invalid, explain why.

  Create a simple text editor that has one large rich text box

Complete the following programming exercise (SIMPLE TEXT EDITOR WITH ONE LARGE RICH TEXT BOX). You will use the OpenFileDialog, StreamReader and StreamWriter objects; the Close, Peek, ReadLine, ShowDialog and WriteLine methods.

  Prepare a c program to read in a word from a user

Prepare a C program to read in a word from a user and check if that word is a palindrome :a word, phrase, or sequence that reads the same backward as forward.

  Calculate and displays the number of slices of pizza

The manager of a pizza palace wants a program that calculate and displays the number of slices of pizza into which a circular pizza can be divided . The manager will enter the radius of the entire pizza.

  Implementation of matrix multiplication

Show the matrix product and implementation of matrix multiplication. Please show me all the working and provide the answer.

  Returns the value of the arithmetic sum up to n

Write and test the following function that returns the value of the arithmetic sum up to neg. SumUpto(5) = 5+4+3+2+1 =15int SumUpto(int)

  Prompt the user for and read 6 numbers

Write a program using an array that will store input data. Prompt the user for and read 6 numbers between 70 and 90. Verify the numbers should be greater than 70 and less than 90. If the number is less than or equal to 70 or greater than 90, repro..

  Write a program to find how much time takes to travel

Write a program C. An object is traveling "x" miles/second after every 2 minutes its current and speed is decreased by 1.7%. How much time it takes to travel "y" kilometers from its origin

  Create a text-based, menu-driven program

Create a text-based, menu-driven program that allows the user to choose whether to add, subtract, multiply or divide two numbers. The program should then input two double values from the use

  Write a program that will be used to gather statistical data

Write a program that will be used to gather statistical data about the number of movies

  Write a sumo robot c program

Write a sumo robot c program for an aduino board, using 2 motors. 2 phototransistors and 2 Led sensors( sensors 2 for the front and 2 for the back ) which are going to be responsible for keping the robot in the sumo ring, making sure the robot com..

  Write the definition of the member function two of yclass

Write the definition of the member function two of yClass so that the private member variable a is initialized to the value of the first parameter of two, and the private member variable b is initialized to the value of the second parameter of two..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd