Anda di halaman 1dari 3

CS211 Programming I for Engineers Professor Ziegler 40 points (out of 200)

Write a C program as follows: (note that an initial block comment and flow charts are not required). However, all other good programming procedures including indenting, comments, bracket alignment, etc. must be utilized.

Begin with your own Lab 8. Modify the lab so that the function you wrote to print the accounts meets the following requirements: #1 RULE: You must use pointers to reference any variables passed into the print function that will be described later. If you use indexing via non-pointers (ie. [x]), then your grade for take-home portion of the exam will be zero (out of 40) regardless of any other work you completed for the exam. MAIN: 1. Create the supporting code necessary to call the print function which will consist of 3 parameters, all passed by reference using pointers: a. The array that holds all of the account information b. The number of rows in the array c. The number of columns the array 2. You must use pointers to reference all of the variables passed into the print function FUNCTION: 1. The function will receive at least three parameters as described above. These 3 parameters must be passed by reference using pointers. 2. The function must work for ANY size array, not just 10 x 3. However, you may pass in the exact array dimensions from main. 3. All requirements for the print function from Lab 8 must still be met. 4. Be sure to print the array of records in rows by customer (just as in the original Lab 8) 5. HINT: I used a FOR loop to traverse the pointer through the array and had to modify the counter (i) to end the loop In other words, I had to do more to the variable i than just increment by one. 6. Because you are using a Pointer to navigate through the array of records, you will not be able to print a row of data as easy as you did when using indexing because the pointer does not know where a row begins or ends. I used remainder divide of a counter (to count where I am in the array) by the number of columns - it is time for a new row when the counter is divisible by the number of columns in the original array. HINT: Dont just divide by 3 remember that your print function must work for any size array. 7. Because you are using a pointer to navigate through the array of records, you will run into a problem when printing the account number because it must appear as an integer, as opposed to savings and checking which should appear as floats, because the pointer does not know where the first column of each row is located. I used the technique described above to know when the pointer was at the first element of each row and printed that element as an integer (actually as a float with 0 digits to the right of the decimal point).

8. My program stops printing the array whenever it finds an element = 0. This does not work well because the program ceases printing when an existing customer has a checking or savings balance = 0. However, for the sake of time, you do not have to resolve this particular situation, even though there may be additional customers further into the array. 9. Submit this assignment with all of the functionality of the original Lab 8 in addition to the changes outlined here. In other words, the program you submit must be able to add, delete, deposit, withdraw, print, and exit, just as it did for the original Lab 8. 10. Your output should appear as shown in the sample run below:

P.T.O

Grading: POINTS = 40 100%. Only pointers can be used to access the arrays in this assignment! No box indexing [ ] is permitted). If box indexing is used, the grade for this portion of the test will be 0 out of 40.
Initial block comment and flow charts are not required.

Do not be concerned with warnings produced by the compiler.

MAIN: 1. 10% Formatting, brackets line up, comments, good variable names, etc 2. 10% Supporting code necessary to call the print function 3. 10% (actually, this is 100%) If pointers are not used the grade is 0) Call the print function - all parameters passed by reference using pointers: a. The array that holds all of the account information b. The number of rows in the array c. The number of columns the array FUNCTION: 1. 10% all parameters passed by reference using pointers: (actually, this is 100%) d. The array that holds all of the account information e. The number of rows in the array f. The number of columns the array 2. 10% Must work for ANY size array, not just 10 x 3 3. 10% print the array of records in rows by customer 4. 10% print the account number without a decimal point 5. 10% print savings and checking with 2 digits to the right of the decimal point 6. 10% all of the functionality of the original Lab 8 in addition to the changes outlined here - add, delete, deposit, withdraw, print, and exit. 7. 10% Your output should appear as shown in the sample run below. 8. No penalty: - program stops printing the array whenever it finds an element = 0. This does not work well because the program ceases printing when an existing customer has a checking or savings balance = 0. However, for the sake of time, you do not have to resolve this particular situation, even though there may be additional customers further into the array. Submit as Instructed: Due: In Lab the last week of classes NOTE REVISED LATE PENALTY: Up to 3 hours late, grade is 50%. After 3 hours late, grade is zero. Check with your lab assistant for instructions on how he wishes you to hand in this portion of your test.

Anda mungkin juga menyukai