assn5 - MIT OpenCourseWare http:/ocw.mit.edu 6.096...

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

View Full Document Right Arrow Icon
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms .
Background image of page 1

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

View Full DocumentRight Arrow Icon
MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.096: Introduction to C++ IAP 2009 PROBLEM SET 5 Part 1: Explain the output of the following code without running it: struct data { float z; char type; }; int main() { data D1 = {20, 'P'}; cout << D1.z++ << D1.type << endl; data D2; D2.type = D1.type; D2.z = 4 * D1.z; Cout << ++D2.z << D2.type << endl; Cout << D1.z-- <<D1.type; return 0; } Part 2: Debug the following program. Include the entire fully functional program as your answer. class member { int memberNum = 25; float memberPay; public void Input(cin >> memberNum >> memberPay); void Output; } int main() { Member mem; cin >> mem.memberNum >> mem.memberPay; cout << mem.memberNum << '\t' << mem.memberPay; } void Output::Member() { cout << mem.memberNum << '\t' << mem.memberPay; }
Background image of page 2
Part 3: 1. Define a class Account (to indicate bank accounts) with the following specifications: a. Data members in private visibility mode (remember that the default visibility mode is private): i. Account number (long integer) ii. Name of the depositor (string object) iii. Type of account (character type value which stores either ‘S’ for saving and ‘C’ for checking) iv. Balance Amount (double) b. Member functions in public: v. To input the value of all data members based on values inputted by the user. vi. To deposit money (the function should take an argument called amountToDeposit , increment the current balance amount by this value, and return the new balance) vii. To withdraw money from the account. It should do what the previous case did with a similar argument named
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/14/2011 for the course DDDD h0322 taught by Professor Whoknow during the Spring '11 term at Bina Nusantara University.

Page1 / 5

assn5 - MIT OpenCourseWare http:/ocw.mit.edu 6.096...

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

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