COSC 1436 Lab 6
Purpose: This lab is in two parts, the first part focusing on UNIX commands and the second part on writing two C++ programs. The first program uses the string class that we used in COSC 1435 and is a review of many concepts you learned in 1435. The second program has exactly the same functionality as the first but uses cstrings introduced as part of 1436.
Due: Section 2: Before class on March 5, Section 3: Before class on March 7
Video Introduction: I am planning to do a video introduction for this lab, where I will get you started on the cstring version of this lab. It should be available in Blackboard by the start of lab.
Requirements C++ Programs: You will be writing two C++ programs for this lab. The requirements for both programs are the same, the only difference is the first will use the cstrings and the second will use the 'string class'. You may write either program first. All of the cstring functions must be safe versions (strcpy_s, strcat_s, strncpy_s, and strncat_s), as we wrote in class. For this program you will be processing a file of information about books. Each programs should properly use a minimum of 3 functions.
1. You will be printing a report, for the books in the file, that gives the ISBN, the title of the book, the wholesale sales price, sales of this title over the last year, returns over the last year, and net sales (total sales - returns) in both wholesale dollars and books.
2. This report should also summarize the information by providing, for the selected books, a total number of books sold and books returned in both quantity and wholesale dollars and total net sales in dollars (sold - returns). In addition the report should show a count of the titles in the report. (I recommend that you check with other students in the class to verify that these results match.)3. Required. Prepare a lab report/documentation package. All of these items do not need to be in the same file or word document, but the main lab report file must reference each item by name. Make sure a digital copy of each item is attached to your email. The lab report must includes the following information:
- Your Name
- Purpose of this program.
- Program psuedocode
- Program source code
- Program output
- How was this program tested?
- What problems/successes did you have with this program?
- An estimate of how much time you spent working on this lab
4. Required. Code the entire program, using cstrings and the functions described in Table 10-3, and based upon your pseudocode. This program must have at least 3 functions you have written. The program should include extensive comments. Save the program as lab06AXXX.cpp (put your initials in the place of the XXX). Compile and run this program and make sure it provides the proper output. NOTE: If you learned to use a struct in COSC 1435, you may use structs in this program. Otherwise use parallel arrays as described by Gaddis in Section 7.6 of the text.
5. Required. Make a copy of your code from the previous step. Revise this code so that the string class is used instead of cstrings. You may use any string class functions or operators described in Tables 10-5, 10-6, and 10-7. This program must have at least 3 functions you have written. The program should include extensive comments. Save the program as lab06BXXX.cpp (put your initials in the place of the XXX). Compile and run this program and make sure it provides the proper output. NOTE: If you learned to use a struct in COSC 1435, you may use structs in this program. Otherwise use parallel arrays as described by Gaddis in Section 7.6 of the text.
6. Required. You will be submitting this lab via Blackboard, as demonstrated in class. You will need to zip your files together and then upload your zipped submission to Blackboard. Make sure you include the source code and the rest of the documentation package, but not the executable files.
1. In this file each record is on a single line that ends with a NEWLINE symbol. The fields in each record are separated by a '|' (ASCII value 124). The fields are of variable size, but the maximum size is given in the table below. The record layout is as follows:
Field Maximum Length Notes Decimal Position ISBN 10 The ISBN is an international code used to uniquely identify all books. It is always 10 characters in length. N/A Title 60 The books title N/A Book Sales 5 The quantity of books sold during the period. No decimal Book Returns 5 The quantity of books returned from book sellers to the warehouse during the period. No decimal not used 5 Wholesale Sale price 5 The wholesale price of the book (the price the company sell the books to the book sellers). 999.99 There is an implied (understood, but not present), decimal point between the 3rd and 4th numbers. Not used 70 N/A
There are unused fields in this record. The record is ended by a '|' immediately follwed by a NEWLINE.
2. LINUX/UNIX and Windows use slightly different file formats to store information. Here is the version of the data file 'books03Delimited.dat' for windows. Here is the version of the data file 'books03DelimitedUNIX.dat' for LINUX/UNIX. The maximum size a record can be 160 characters plus the new-line character. Remember to leave space for the null terminator in all cstrings.
Grading Criteria: 100 points available for this lab. The lab grader will be using this grading criteria to grade your two programs.