Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a menu-driven program to keep track of the inventory and sales for a vending machine companys machines at various college campuses. Input File vendingMachines.txt

Write a menu-driven program to keep track of the inventory and sales for a vending machine companys machines at various college campuses.

Input File vendingMachines.txt

Contains the data for each of the machines. The data on each machine consists of 6 lines of input. The first line contains the location (college), 5 additional lines contain a number representing the number of bottles in the machine for each of the brands Coke, Diet Coke, Sprite, Sprite Zero and Dasani.

Data from input file:

Sinclair Community College 0.50 6 0.75 5 0.50 9 0.75 4 1.00 3 Wright State University 0.90 4 1.00 6 0.90 3 1.00 2 1.25 4 University of Dayton 1.00 3 1.25 5 1.00 2 1.25 6 2.00 4 The Ohio State University 0.80 5 0.90 4 0.80 7 0905 3 1.50 2 Clark State Community College 0.75 1 0.85 2 0.75 4 0.85 2 1.00 5 Ohio University 1.00 2 1.25 6 1.00 7 1.25 3 1.50 2 

Requirements

Use the following Structure

enum SodaBrands {COKE, DIET_COKE, SPRITE, SPRITE_ZERO, DASANI};

struct Drinks

{

double price;

int numSodas;

};

const int MAX_SODA_BRANDS = 5;

struct vendingMachine

{

string location;

Drinks sodas[MAX_SODA_BRANDS];

};

Define an array of vendingMachine structs to store the data from the input file. Assume that there are no more than 10 vendingMachines. NOTE that each struct contains an array of Drinks structs indexed by the enumerated type SodaBrands.

Main Program

Read the input file into the array of structs

Use a while loop, calling functions to display the menu of locations and input the users location choice, and process the users selection.

At the beginning of the program display the contents of the array to show the beginning inventory.

At the end of the program display the contents of the array to show that the inventory has been updated based on the sales.

Suggested Functions

void loadVendingMachines (vendingMachine[]);

reads the input file, transferring the input data into the array of structs

void showVendingMachines (vendingMachine[]);

displays the contents of the vendingMachine array

SodaBrands convertDrink (string);

Translates a string into an enum value. (for example, string Coke returns enum value COKE.

void getDrinkName (SodaBrands, string&);

Translates an enum value into a string. (for example, enum value COKE returns string Coke)

int getLocation(vendingMachine[]);

Displays the list of locations (i.e. the menu), reads in and validates the location number entered by the user.

int getDrinkSelection ();

Displays the menu of soda choices by looping through the enum values

Reads in the users selection

void makePurchase (vendingMachine[], int, int);

Displays amount due (price of selected soda for that particular location)

Asks user to enter money

Calculates and displays change due

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

Draw a picture consisting parts of monocot leaf

Answered: 1 week ago