//============================================================================
// 제출일 : 2005. 3. 12
// 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4
// 연습문제 4-38
//============================================================================
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
float calc(float input); //이자의 계산
void print(float input); //출력
int main()
{
float begining_balance;
cout << "원금을 입력하세요\n";
cin >> begining_balance;
print(begining_balance); //출력 함수 호출
return 0;
}
float calc(float input) //이자 계산 함수
{
return (float)(input * 0.053);
}
void print (float input) //출력함수 : 이자 계산 함수 호출
{
int loop ;
cout << "============================|\n";
cout << "|Quater| Interest | Total |\n";
cout << "============================|\n";
for (loop = 0; loop < 5 ; loop++)
{
cout.setf( ios::right, ios::adjustfield ); //오른쪽 정렬
cout <<'|'<<setw(6)<<loop <<'|';
cout <<setw(10)<<calc(input)<<'|'; //이자의 계산
input+=calc(input); //계산된 이자를 원금에 합산
cout <<setw(9)<<input<<"|\n"; //최종 잔액 출력
}
cout << "=================================\n";
}
'Studies > A Structured Approach Using C++' 카테고리의 다른 글
Project 4-40 Random number 랜덤 (0) | 2008.08.23 |
---|---|
Project 4-39 Temperature convertor : Fathrenheit VS Centigrade 온도변환기 : 화씨 섭씨 (0) | 2008.08.23 |
Project 4-37 Prepare a payroll earnings statement (0) | 2008.08.23 |
Problem 4-35 print the ceiling, floor, and rounded value of a floating-point number (0) | 2008.08.23 |
Problem 4-33 Modify the "Add two digit" grogram (0) | 2008.08.23 |