TAILIEUCHUNG - Absolute C++ (4th Edition) part 28

Absolute C++ (4th Edition) part 28. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | Constructors 273 Display Bank Account Class part5 of 5 161 return static_cast int amount 162 163 Uses cmath 164 int BankAccount centsPart double amount 165 166 double doubleCents amount 100 167 int intCents round fabs doubleCents 100 can misbehave on negatives 168 if amount 0 169 intCents -intCents These could be regular functions rather than member functions 170 return intCents but as member functions we were able to make them private. 171 172 Uses cmath if this does not seem clear see 173 int BankAccount round double number the discussion of round in 174 Chapter 3 Section . 175 return static_cast int floor number 176 177 double BankAccount fraction double percent 178 179 return percent 180 Sample Dialogue accountl initialized as follows Account balance Rate account2 initialized as follows Account balance Rate 0 accountl reset to the following Account balance Rate Enter new data for account 2 Enter account balance Enter interest rate NO percent sign 10 account2 reset to the following Account balance 100 Rate 10 In one year account2 will grow to Account balance 110 Rate 10 274 Constructors and Other Tools Self-Test Exercises 3. The function BankAccount input in Display reads the balance of the account as a value of type double. When the value is stored in the computer s memory in binary form this can create a slight error. It would normally not be noticed and the function is good enough for the demonstration class BankAccount. Spending too much time on numerical analysis would detract from the message at hand. Still this input function is not good enough for banking. Rewrite the function BankAccount input so it reads an amount such as as the int 76 and the three char values . 9 and 6 . You can assume the user always enters two digits for the cents in an amount such as instead of just 99 and nothing more. Hint The following formula will convert a digit to the corresponding int value such as 6 to 6 .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.