88
2012-07-19 04:37:48
0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int read_type(){
int num_menu=1;
printf("=======================n");
printf("1 : 사업가용 n");
printf("2 : 직장인용 n");
printf("3 : 대학생용 n");
printf("예금의 종류를 정해 주세요 : ");
scanf("%d",&num_menu);
return num_menu;
}
int read_amount(){
int amount;
printf("예금액을 입력해 주세요 : ");
scanf("%d",&amount);
return amount;
}
int read_duration(){
int dur;
printf("예치 기간을 입력해 주세요(단위 개월) : ");
scanf("%d",&dur);
return dur;
}
float compute_interest_1(float acc_rate, int acc_duration){
return pow(acc_rate,(float)acc_duration);} //pow 라이브러리 함수 사용
float compute_interest_2(float acc_rate, int acc_duration){
int interest;
return 0;} // total *=(1+acc_rate)를 n번 반복 n은 정수, 소수점 이 되면 소수점 이하 버림. 사용 합수 floor
float compute_interest_3(float acc_rate, int acc_duration){return 0;} //재귀 함수.
float compute_total(int acc_type, int acc_amount, int acc_duration){
float total_1,total_2,total_3;
int year = acc_duration/12;
float acc_rate;
float interest_1;
float interest_2;
float interest_3;
int i;
float temp_amount=(float)acc_amount;
switch(acc_type){
case 1:
acc_rate = 1.04;
break;
case 2:
acc_rate = 1.06;
break;
case 3:
acc_rate = 1.08;
break;
}
interest_1 = compute_interest_1(acc_rate,acc_duration);
total_1 = acc_amount*interest_1;
for(i=0;i<=year;i++)
temp_amount *= (1+acc_rate);
total_2=temp_amount;
temp_amount=(temp_amount-acc_amount)/acc_amount;
interest_2 = temp_amount;
interest_3 = compute_interest_3(acc_rate,acc_duration);
total_3 = acc_amount*(1 + interest_3)*year;
printf("원리합계 =============n");
printf("방법1, 원금 : %d, 총이자율 : %d, 예치 기간 : %d, 원리합계금액 : %d n", acc_amount,interest_1,acc_duration,total_1);
printf("방법1, 원금 : %d, 총이자율 : %d, 예치 기간 : %d, 원리합계금액 : %d n", acc_amount,interest_2,acc_duration,total_2);
printf("방법1, 원금 : %d, 총이자율 : %d, 예치 기간 : %d, 원리합계금액 : %d n", acc_amount,interest_3,acc_duration,total_3);
return total_1;
}
int main(int argc, char *argv[])
{
int acc_type, acc_amount, acc_duration, acc_total;
acc_type = read_type(); //예금 종류를 입력받는 함수
acc_amount = read_amount(); //예금액을 입력받는 함수
acc_duration = read_duration(); //예금 기간을 입력받는 함수
//원리합계를 계산하는 함수
acc_total = compute_total(acc_type, acc_amount, acc_duration);
system("PAUSE");
return 0;
}
도저히 졸려서 못해먹겠네요.
차라리 치킨집 전화하셔서 물어보시는게 빠를듯.
그리고 혹시 맘있으시면 유니세프에 기부해주세용