pa10 - CMPS 150 Spring 2007 Programming Assignment #10...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPS 150 – Spring 2007 Programming Assignment #10 2007.04.30 Date Assigned: Monday, April 30, 2007 Due Date: 3:00 PM, Sunday, May 6, 2007 The coded solution for the following problem is to be done by you and only you. You may ask for help from the class teaching assistants and the instructor, but you may not ask for C++ help from anyone else. You may use your notes, C++ texts, online tutorials, etc., but the code must be your own. If you have a problem with your class account, compiling or debugging your code, or if you are not certain if you have submitted correctly, come see a TA or instructor as soon as possible. 1) Include the following information as comments in the header of your source code: // Author: Your-Name // CLID: Your-login-ID // Class: CMPS 150 Section Your-Section-Number // Assignment: pa10 // Date Assigned: Monday, April 30, 2007 // Due Date: 3:00 PM, Sunday, May 6, 2007 // Description: A brief description of the purpose of the program. // // Certification of Authenticity: // I certify that this assignment is entirely my own work. 2) Enter the C++ code for the following description into a file named pa10.cpp in your class folder. 3) Problem Description: This program will use many concepts already covered in CMPS 150, but will focus on functions, arrays (both 1D and 2D) and structs (records). It is a set of "exercises" in manipulating structs and arrays. One part of this program will use a struct to store information about products available in a vending machine. One option available to the user is to read data into an array of vending machine records (structs) from a file (name provided by the user). The format of the file is shown at right. The information is in "triplets" – that is, a product name (which may contain spaces) on a line by itself, followed by the quantity available, followed by the unit price. There can be no more than 20 (hint: constant ) different items in the vending machine. Each struct (record) is defined as: struct Vending { string name; int quantity; double unitPrice; }; Since the input from this file involves using both the getline statement and the extraction operator (>>), special precautions must be taken to handle this mixture of input statements. A sample of reading one "set" of data is given on the following page. Again, mixing getline with >> requires special handling. NOTE: This assignment is worth 4% of your overall grade !! ALSO: No late assignments accepted !! Potato Chips 12 0.75 Candy Bar 12 0.75 Gum 25 0.60 Cookies 10 1.25 Mints 15 1.00 ... ... ...
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CMPS 150 – Spring 2007 -- Programming Assignment #10 Priming Read Statement for Input of Vending (struct) Information: // priming read to get the first "set" of data getline(inFile,itemName); inFile >> itemQuantity >> itemUnitPrice; getline(inFile,dummyString); // this gets the '\n' after the // unitPrice that the >> operator // leaves behind The second part of this program will manipulate a 2-dimensional array of integers. There will be exactly 10
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

pa10 - CMPS 150 Spring 2007 Programming Assignment #10...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online