CS 1428 Programming Assignment 2 Due Wednesday September 19 th 2018 11:15 am Section 3 3:45 pm Section 4 Program 2: Write a C++ program to create a customer s bill for a company. The company sells only five different products. TV, VCR, remote Control, CD Player, and Tape Recorder. The unit prices are $400.00, $220.00, $35.20, $300.00, and $150.00 respectively. The program must read from the keyboard the quantity of each piece of equipment purchased. It then calculates the cost of each item, the subtotal, and the total cost after an 8.25% sales tax. The input data consist of a set of integers representing the quantity as shown below. The number in boldface shows the user s answer How many TV were sold? 3 How many VCR were sold? 5 How many remote controls were sold? 1 How many CD s were sold? 2 How many tape recorders were sold? 4 The format for the output from the program is : QTY DESCRITPTION UNIT PRICE TOTAL PRICE ----- --------------------- ---------------- ------------------ XX TV 400.00 XXXX.XX XX VCR 220.00 XXXX.XX XX REMOTE CONTROL 35.20 XXXX.XX XX CD PLAYER 300.00 XXXX.XX XX TAPE RECORDER 150.00 XXXX.XX -------------- SUBTOTAL XXXX.XX TAX XXX.XX TOTAL XXXX.XX Husain Gholoom Lecturer in Computer Science 1
Note : Use constants for the unit prices and the tax rate. Use integer variables to store the quantities for each item. Use floating-point variables to store the total price for each item, the bill subtotal, the tax amount, and the total amount of the bill. Style Guidelines : At the beginning of your program ( and before the #include statement ), include the following : Header comments (file documentation block) should be at the top of each file and should contain: Author / s, Due Date, Assignment Number, Course number and section, Instructor, and a brief description of the purpose of the code in the file. For example : Author / s : (Your name here!!) Roster Number : Due Date : Programming Assignment Number 2 Fall 2018 - CS 1428 - Section Number Instructor: Husain Gholoom. <Brief description of the purpose of the program> Variable names : Must be meaningful. The initial letter should be lowercase, following words should be capitalized, no other caps or punctuation ( i.e. weightinpounds ). Each variable must be declared on a separate line with a descriptive comment. Husain Gholoom Lecturer in Computer Science 2
Named constants : Use for most numeric literals. All capitals with underscores ( i.e. TX_STATE_SALES_TAX ) Should occur at top of function, or global (only if necessary) Line length of source code should be no longer than 80 characters (no wrapping of lines). Indentation : Use 2-4 spaces (but be consistent throughout your program). Indent blocks, within blocks, etc. Use blank lines to separate sections. Comments for variables : All variable definitions should be commented as follows: int gender; integer value for the gender, 1 = Male, 2 = Female, Remarks: 1. Your program must compile and run using the latest version of Code::Blocks IDE. 2. Your program must be documented according the style above. See the website for the sample programming style program. 3. Must properly format the output by use the appropriate library 4. You must name your program as : 1428_3_F18_PA2_XXXXX_YYYYYY.cpp ( for Section number 3 ) 1428_4_F18_PA2_XXXXX_YYYYYY.cpp ( for Section number 4 ) Where XXXXX is your Last Name and YYYYYY is your First Name. For example, the file name should look something like : 1428_3_F18_PA2_Gholoom_Husain.cpp ( not.cbp ) Husain Gholoom Lecturer in Computer Science 3
You must upload your programs no later than the starting of class time on the due date. No late assignments will be accepted. 11:16 am or 3:46 pm and after will be considered late and will not be accepted. Use TRACS To upload your program 5. You must also turn in hard copy of your source code no later than the starting of class time on the due date. should the hard copy consist of more than one page, then, the hard copy must be stapled. if you are unable to turn in a printout during class, you can take the program to the computer science department and hand it to the front desk personal (Comal 211 ) before the deadline. Make sure that the front office stamps the program. Make sure that include the date and time. Finally,make sure that they place the program in my mailbox. DO NOT slide your program under my office door It will NOT be accepted 6. The following points will be deducted if : Incorrect file format such as uploading.cbp instead of.cpp ( - 10 ) points Compilation Errors ( - 8 points ) Logical Errors ( - 1.25 points ) Incorrect Output format ( - 1.25 points ) Incorrect file name ( - 1.25 points ) Incorrect Style such as Missing Header or footer, missing comments or documentations, hard copy not stapled, hard copy is difficult to read, not using constant variable etc ( - 1.25 points each ) Husain Gholoom Lecturer in Computer Science 4
Sample Run Hi Five Electronic Store How many TV were sold? 3 How many VCR were sold? 5 How many remote controls were sold? 1 How many CD s were sold? 2 How many tape recorders were sold? 4 QTY DESCRITPTION UNIT PRICE TOTAL PRICE ----- --------------------- ---------------- ------------------ 3 TV 400.00 1200.00 5 VCR 220.00 1100.00 1 REMOTE CONTROL 35.20 35.20 2 CD PLAYER 300.00 600.00 4 TAPE RECORDER 150.00 600.00 ---------------- SUBTOTAL 3535.20 TAX 291.65 TOTAL 3826.85 Prepared by Husain Gholoom Husain Gholoom Lecturer in Computer Science 5