How to create a coke machine program in c++

Assignment Help Computer Engineering
Reference no: EM1331477

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: EM1331477

Questions Cloud

Explaining unemployment benefits : Mr. Jones' only recourse is to file for unemployment benefits.
Write down a simple c++ cash register program : The program must ask for the customer's first name and last name initials. Use 2 different variables, one for the first name and one for the last name.
Risk-averse von neumann-morgenstern perticular : Prove that a risk-averse von Neumann-Morgenstern perticular will over-insure, fully-insure, or under-insure according as the insurance is available
Resources for marketing principles : Resources for Marketing Principles - Summarize information from your online resources and write a summary journal entry for each.
How to create a coke machine program in c++ : We would 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.
Training and management development activities : What kinds of training and management development activities have you experienced that have benefited your career and Where do you seeing training and development going in the future within your organization
Explain e-business ethics and regulations affecting consumer : Would like to understand why these issues are any different in e-business as they would be in a brick and mortar business.
It is impossible to select as bmw and laser printers : It is impossible to select as BMW's and laser printers are fundamentally different goods with different purposes.
In brief describe rudimentary nms : Briefly explain rudimentary NMS (network management system) software components and the software applications that are required to support a network system.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Make an idef1x e-r diagram

The scenario is that the Public Affairs Office at Highline University receives requests for speakers on particular topics. To be capable to respond to such request, that office wants to build a database.

  Outline the importance of support systems and mechanisms

examine how creating Risk Management, Scope Change Control, and Communication Plan can help improve the management of any project.

  Exploring substantial component of information security

Explain the weaknesses in the controls? Specify whether there exist any new or upgraded access controls being considered? Let us explore this substantial component of the information security.

  Design an application that instantiates five clients

The law firm of Howard, Fine and Howard wants to develop two classes- a Client class that holds data about the firm's clients and an attorney class that holds data about each of attorneys who work for the firm.

  Describe python modules and packages

Describe Python modules and packages

  Plan a program that asks for the student''s name

Your English instructor, realizing you are a programmer, asks you to write down a Grade Book program for his class to help him compute final grades. plan a program that asks for the student's name and four test grades. Display the student's name, ..

  Discuss the layered stack approach

This is meant as a discussion topic, this is not an essay. Describe the OSI and TCP/IP reference models. express  the similarities and differences between them. consider how the layered stack approach assists in our understanding of these referenc..

  Design a class diagram for the ticket-processing system

Design a class diagram for the ticket-processing system

  Program would update the account to reflect payment

After discussing this with your uncle, you agree to set up a computer and make a program that would keep track of his clients. It would calculate the bills and print invoices that would be mailed to the clients. It will also keep track of the clie..

  Computing the fmin value

Compute the minimum: Graphically, Numerically with the f min search function

  Figure out how opening multiple simultaneous connections

I know the processor deals with each request either by LIFO or FIFO and never gets confused about what to do and I am sure it could handle such pressures like opening multiple pages all at one time well.

  Context free language

Let L1 be the regular language and L2 be the context-free language, both described over the same alphabet Σ. a) Is L1∩L2 always regular? Explain your claim.

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