#include <stdio.h>
#include <math.h>
int acc_type, acc_amount, acc_duration; //main함수가 시작하기전에 acc_변수를 선언//
float acc_total;
int read_type(); //함수 원형//
int read_amount();
int read_duration();
float compute_total(Type, Amount, Duration);
int main(void)
{
acc_type = read_type(); //함수 호출//
acc_amount = read_amount(); //함수 호출//
acc_duration = read_duration(); //함수 호출//
acc_total = compute_total(acc_type, acc_amount, acc_duration); //함수 호출//
printf(\"\\n원리합계는 %f원 입니다.\\n\\n\", acc_total);
return 0;
}
int read_type() { //함수 정의//
int type;
do
{
printf(\"\\n 원하시는 상품을 선택해주세요.\\n\\n\");
printf(\" 1) 직장인용 예금상품 : 이자율 6%\\n\");
printf(\" 2) 사업가용 예금상품 : 이자율 4%\\n\");
printf(\" 3) 대학생용 예금상품 : 이자율 8%\\n\\n\");
printf(\" 선택 : \");
scanf(\"%d\", &type);
} while(type < 1 || type > 3);
return type;
}
int read_amount() { //함수 정의//
int amount;
printf(\"예금할 금액을 입력해주세요 : \");
scanf(\"%d\", &amount);
return amount;
}
int read_duration() { //함수 정의//
int duration;
printf(\"입력할 기간(월)을 입력해주세요 : \");
scanf(\"%d\", &duration);
return duration;
}
float compute_total(Type, Amount, Duration) { //함수 정의//
float rate, total;
if(Type = 1) {
rate = 1.06;
}else if(Type = 2) {
rate = 1.04;
}else if(Type = 3) {
rate = 1.08;
}
total = Amount * pow(rate, Duration/12);
return total;
}
형님들 여기서 메인함수가 저렇게 끝나지 말고요
다시 입력하시겠습니까? 물어보고
다시 입력하겠다고하면
위에꺼 다 지워지고
다시 처음부터 하게는 어떻게 해야될까요?
메인함수를 do~while로 감싸서 특정키 입력하면 빠져나오게해 요 그리고 [...] 하면되겟네요 [핡]
[...] 이거말고 방법없을까요? 이건 배우질 않아서 ㅠㅠ
미치겠네... 답변주자니 나한텐 무한루프로 맨날 같은 내용만 올리는거 같아서..ㅡ.,ㅡ
여기 질문 올리는 좆뉴비들은 검색능력이 졸라 딸리나봐...ㅡ.,ㅡ
시스템 cls가 화면지우는건데... [핡]