Docsity

CS 226 Programming Assignment 1: Product Sales Report, Assignments of Computer Science

Toggle sidebar
bg1
CS 226 – Intro. to O-O Programming w/C++: Programming Assignment 1
1. Write a data entry program to meet the following specification and requirements.
A wholesale hardware distributor sells five products, number 1-5, at the unit prices indicated:
Product Unit Price
1 $2.98
2 $3.25
3 $8.47
4 $5.15
5 $4.24
At the end of each sales period the data entry personnel use a computer application program
to enter the quantities of each product that has been sold to various retail outlets. The data is
entered as pairs of numbers (as integers, not characters) that represent a product and the
quantity sold. The user has the option of quitting the program before entering any data, e.g.:
Product Data Entry Program. Do want to continue?y/n y
Enter product and quantity: 2 7
Continue product and quantity entry?y/n
After data has been entered the user is prompted to continue entering more data or quit the
process as shown above. Input for the “y/n” response will be taken as character data. Entry
of product and quantity data will continue until the user enters ‘n’ at the “continue” prompt.
Multiple entries of the same product are allowed and the totals “accumulate”. When the
user is through entering data the program will calculate individual sales totals for each
product and the total sales for all product sales for the data entry period, then print a report
to the screen formatted as shown below.
Product Sales Report:
Product Qty Totals
1 3 8.94
2 5 16.25
3 4 33.88
4 2 10.30
5 12 50.88
Total Sales 120.25
If the user quits the program before entering any data the program should display some kind
of appropriate message instead of printing a report, e.g.:
Product Sales Report: no product data entered.
2. There are several specific programming requirements for the program as follows:
the program must use a while loop for the repetition construct
the program must use a switch selection construct for handling product detection
the program must handle invalid product numbers with an appropriate error message,
e.g.:
Enter product and quantity: 7 4
Invalid product code: 7
the program must handle inputs of uppercase and lowercase letters, i.e. ‘n’ and ‘N’
1
pf2

Partial preview of the text

Download CS 226 Programming Assignment 1: Product Sales Report and more Assignments Computer Science in PDF only on Docsity!

CS 226 – Intro. to O-O Programming w/C++: Programming Assignment 1

  1. Write a data entry program to meet the following specification and requirements. A wholesale hardware distributor sells five products, number 1-5, at the unit prices indicated: Product Unit Price 1 $2. 2 $3. 3 $8. 4 $5. 5 $4. At the end of each sales period the data entry personnel use a computer application program to enter the quantities of each product that has been sold to various retail outlets. The data is entered as pairs of numbers (as integers , not characters) that represent a product and the quantity sold. The user has the option of quitting the program before entering any data, e.g.: Product Data Entry Program. Do want to continue?y/n y Enter product and quantity: 2 7 Continue product and quantity entry?y/n After data has been entered the user is prompted to continue entering more data or quit the process as shown above. Input for the “y/n” response will be taken as character data. Entry of product and quantity data will continue until the user enters ‘ n ’ at the “continue” prompt. Multiple entries of the same product are allowed and the totals “accumulate”. When the user is through entering data the program will calculate individual sales totals for each product and the total sales for all product sales for the data entry period, then print a report to the screen formatted as shown below. Product Sales Report: Product Qty Totals 1 3 8. 2 5 16. 3 4 33. 4 2 10. 5 12 50. Total Sales 120. If the user quits the program before entering any data the program should display some kind of appropriate message instead of printing a report, e.g.: Product Sales Report: no product data entered.
  2. There are several specific programming requirements for the program as follows: the program must use a while loop for the repetition construct the program must use a switch selection construct for handling product detection the program must handle invalid product numbers with an appropriate error message, e.g.: Enter product and quantity: 7 4 Invalid product code: 7 the program must handle inputs of uppercase and lowercase letters, i.e. ‘n’ and ‘N’ 1

CS 226 – Intro. to O-O Programming w/C++: Programming Assignment 1

  1. You will include one function in your program that will be the called as the first executable statement in the main( ) function. Place the prototype (shown below) above the main( ) function and the function definition below the main( ) function. void programData(); // function will print out the following when called: CS 226 Assignment 1 Programmer: Your Name Date: program date
  2. You will write a design for your program using the pseudocode style described and illustrated in the text. There are numerous examples of pseudocode design in chapters 1-4 of C++ How to Program.
  3. Your source code program should conform to the course Programming Style Guide as follows: Add a program heading block at the beginning of the source code file as shown in part 1 of the style guide. Use variables names that conform to the guidelines in part 3 of the style guide. Format your source code as illustrated in sections 5 – 9 of the example program. Your source code should include some comments to explain the logic. For example, you might add a comment like //update total for product 1 .You do not need to overdo the commenting by inserting explanations for things like programming constructs (for example, //this is a while loop ) that are obvious to any programmer – you will need to develop a feel for what is enough but not too much.
  4. Submit the following deliverables via the WebCT Assignment Drop: Your pseudocode design in MS Word document format. The design document should have a heading with your name, date, assignment name, and brief description. Source code file formatted as per the style guide and example program. Name your source file asmt1.cpp. DO NOT use other names for this file. A document showing output from a test run of the program. Do Not paste a screen shot made with Print Screen. See the handout on Working with Console Windows for details on how to configure the console window and copy text from it.
  5. This assignment is due Tuesday , February 15, 2005 before class begins. Late assignments will be penalized 20%. No assignments will be accepted more than 1 week late. Resubmitted assignments that were originally late will retain the late penalty. 2