Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

You have been approached by a company to create a front­end system for a vending machine written in C. The vending machine serves all kinds of pastry treats. The company's name is Penelope's Pastry Delights and as such, the executable you are creating will be called "ppd"

Note: for this assignment you may use either gcc or clang which are both installed on the coreteaching machines. Many developers prefer to use clang as they feel that it provides more friendly error messages. clang accepts the same arguments as gcc so there should not be any problem there.

In this assignment you are to implement an application that will perform the above tasks as a single user model - which will then be used as a prototype for how the new system would look.

You will need to demonstrate your understanding and programming ability, with respect to more advanced C programming principles. The concepts covered include:

• Command line arguments.
• File handling.
• Dynamic memory allocation and linked lists.
• Modularisation and multi­file programs.
• Makefiles.
• Function pointers
• All concepts covered in Assignment #1.

Requirement #1 Command­line arguments

A user of your program must be able to execute it by passing in the names of two data files that the system is to use. You need to check that exactly 3 command line arguments are entered.

Requirement #2 Load Data

Your program needs to be populated with the data provided in the 2 data files whose names are conveyed via the command line. You will need to tokenize this data in order to load it into the system. Use the structure definitions provided in the startup code to store your system data. As part of this requirement you need ensure that the specified files are valid (that is, they exist and the data contained in them matches the specification for this assignment). You need to abort the program and provide a suitable error message if this is not the case.Requirement #3 Implement Main Menu Structure (6 marks)
The main menu data structure is to be implemented as an array of struct menu_item.

Requirement #3  Implement Main Menu Structure

Requirement #4 Display Main Menu

Your program must display an interactive menu displaying 9 options.

Requirement #5 Display Items

This option allows the user to request a display of the items available for purchase.

Requirement #6 Purchase Item

This option allows the user to purchase an item from the menu. This function is called from the main menu when the user has finally decided to purchase an item. This function allows the user to pay for their item by collecting money from them, and adjusting balances within the system as appropriate. Change is then given back to the customer, if appropriate. The number of items on hand should also be deducted. You should not allow an item to be purchased if there are 0 or less of that item on hand.

Requirement #7 Save and Exit

You must save all data to the data files that were provided on the command line when the program loaded up. When the saving is completed, you must have the program exit. The specifications mentioned for each file must be maintained and the program must be able to load up your files as easily as it loaded up the files that we have provided you with. Also, at this point, once you have implemented dynamic memory allocation, you must free all memory allocated and exit the program. A program which does everything but exit the program will still lose marks, as much as a program that does not implement any other requirement.

Requirement #8 Add Item

This option adds an item to the system. When the user selects this option, the system should generate the next available item id and associate that with this item. The user should then be prompted for the Name and Description and Price (a valid amount of money in dollars and cents). The item should then be allocated the default "on hand" value specified in the startup code. The new item id shall have an ‘I' prepended to it and will be 5 characters long.

Requirement #9 Remove Item

Remove an item from a category and delete it from the system, including free memory that is no longer being used.

Requirement #10 "Reset Stock Count"

This option will require you to iterate over every stock in the list and set its 'on hand' count to the default value specified in the startup code.

Requirement #11 "Reset Coin Count"

This option will require you to iterate over every coin in the coin list and set its 'count' to the default value specified in the startup code.

Requirement 12 "Display Coins"

This option will require you to display the coins as follows.

Requirement #13 "Abort"

This option should terminate your program. All program data will be lost. You should also be freeing memory at this point as well.

Requirement #14 Return to menu functionality

Your program should allow the user to return to the main menu at any point during these options. The user can do this by either hitting enter or pressing ctrl­d on an empty line. If the user is in the middle of a transaction, that transaction should be cancelled.

Requirement #15 Makefile

Your program must be compilable using a makefile. All compile commands must include the "­ansi ­Wall ­pedantic" compile options and compile cleanly with these options. Your makefile needs to compile your program incrementally, i.e., use object files as an intermediate form of compilation.

Also include a target called "clean" that deletes unnecessary files from your working directory such as object files, executable files, core dump files, etc. This directive should only be executed when the user types "make clean" at the command prompt.

Have a look at the courseware on blackboard for examples of makefiles. There are also many examples of makefiles provided in the lecture material.

Requirement #16 Memory leaks and abuses

The startup code requires the use of dynamic memory allocation. Therefore, you will need to check that your program does not contain memory leaks. Use the "valgrind ­­leak­check=full ­­show­reachable=yes " to check for memory leaks. Marks will only be awarded for this requirement if the feedback valgrind provides reports zero memory leaks and no other memory related problems.

Another common problem in is memory abuses. These are inappropriate accesses such as reading from uninitialized memory, writing to memory addresses you should not have access to and conditional statements that depend on uninitialized values. You can test for these again by using valgrind:

Requirement #18 Proper Use of an ADT

In this assignment, you are implementing an Abstract data type - a list. One list is implemented as an array and the other list is implemented using a linked list. For this requirement you will need to propose a list of interface functions for each list and implement these. All references to these types should be via these interface functions.

Requirement #19 General requirements

You must read the "Functional Abstraction" "Buffer Handling" , "Input Validation" and "Coding Conventions and Practices" requirements of the "COSC1076 Advanced Programming Techniques General Assignment Information" document.

Requirement #20 Assignment Demonstration

You are required to attend an assignment demonstration in week 10 or 11. You will be required to demonstrate requirements 5,6, 8 and 9 in this demonstration. Please note that this includes implementation of any requirements that these options depend upon. After you have demonstrated your program working you will need to submit your files to weblearn. You will be required to compile and run your program on saturn, jupiter or titan. Please attend your regular scheduled lab.

Attachment:- cp.zip

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91415863
  • Price:- $150

Priced at Now at $150, Verified Solution

Have any Question?


Related Questions in C/C++

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As