Write a program that simulates a soft drink machine

Assignment Help Computer Engineering
Reference no: EM131325381

Purpose

Demonstrate the ability to implement and use structured data types utilizing the facilities of the C programming language.

Assignment

Write a program that simulates a soft drink machine. Your program will consist of two sections. One section will be the functions that make up the drink machine. The second section will be the functions that provide the user interface for the drink machine and allow the user to purchase drinks.

Section 1: The Drink Machine

This describes the operation of the first section of your program. This is the processing that is needed to simulate the Drink Machine.

There will be 1 or more drink types in the machine. Your program will read the number of drink types and the drink information from a file. You must then dynamically create an array of structures that will hold the drink information. You may assume that there are no errors within the input file.

The Drink Machine Input File Format

Here is a sample file that contains the information for one such Drink Machine:

8

 

Cola

1.25 25

Root-beer

1.25 20

Lemon-lime

1.25 25

Water

1.00 40

Orange

1.25 5

Iced-tea

1.25 35

Grape

1.30 15

Iced-Coffee

2.00 35

The first item is an integer that describes how many drinks are described in the input file.

Following that are the drink descriptions. The drink name is first, the cost of the drink is second and the number of drinks in the machine at start up is third. Note that the drink names do not include any spaces in the text.

You can use the C stream function fscanf() to read in the values from the file.

Code

You will be creating your Drink Machine code as a C style program. Your source will be in a file called drinkmachine.c. The structure definitions and function prototypes will be put into a file called drinkmachine.h.

The program will need a couple of structures.

DrinkItem structure

One structure is for a DrinkItem and contains the following information:

id

The drink id (assigned by the program) of type int

name

Drink name (type of drink - read in from a file)

 

price

Drink cost (the retail cost of one drink). This is the price the customer will pay for one drink of this type. This is also read in from a file. Type is double.

 

number of drinks

Number of drinks of this type in the machine. Initial value is read in from a file. This is also updated by the program as people purchase drinks. Type int. Give this a good name.

 

Drinks purchased

Initially 0. Updated whenever a drink is purchased. Type is int. Give this a good name.

DrinkMachine structure

The other structure, for the DrinkMachine, will contain the following information:

 

An int that contains a version number. For this assignment this will have a value of 1.

 

An int that contains the number of DrinkItem structures.

 

An array of Drink Items. Each element of the array will be a DrinkItem structure. You will dynamically create this array based on the contents of an input file you will read in.

 

An int that contains the current location in the array of DrinkItem structures. This is used internally by the drink machine part of your code.

You will choose the names for the structure items.

Attachment:- Assignment.pdf

Reference no: EM131325381

Questions Cloud

Examine the core legal requirements : Examine the core legal requirements affecting employee benefits in today's competitive environment. Determine the legally mandated benefits that the company must currently offer to its employees
Describe the services provided by selected mental health : Select one mental health or crisis intervention human service program that exist within the field of criminal justice to discuss. For example, if you wanted to focus on Domestic Violence, locate a domestic violence program provided by a criminal j..
Universal recipient for blood transfusion : Explain why type AB+blood may be called the "universal recipient" for blood transfusion. Explain why this would not be true if the transfusion required 6 units( about 3 liters) of blood.
Explain the mindset and you will paraphrase : You will also include a metaphor to help your readers understand the concept of a growth mindset.
Write a program that simulates a soft drink machine : Write a program that simulates a soft drink machine. Your program will consist of two sections. One section will be the functions that make up the drink machine.
Before and during fetal lung maturation : Briefly describe the changes in lipid composition of amniotic fluid before and during fetal lung maturation.
Find the combination of notional principals : Find the combination of notional principals that would make your overall position be delta hedged, gamma hedged, and vega hedged.
Identify three laws that affect employee rights : Laws affecting employee rights. Identify three laws that affect employee rights. Include a description and the impact each has on a Human Resource Manager
Purpose of the human genome project : Describe the purpose of the Human Genome project and how it was achieved. Form a hypothesis of future research that could benefit from the HGP.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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