학교과제문제인데요, 맞는거 같은데 자꾸 오류가 나서 질문드립니다.
자동차 모델 년도와 무게에 따라 weight class가 결정되며 weight class에 따라 아래와 같이 자동차 세가 결정된다.(if문과 switch문사용)
1. User 로부터 model year와 weight를 입력 받는다.
2. 입력 받은 정보에 따른 weight class를 계산한다..(if문)
3. 2.에서 계산된 class에 따른 fee계산(switch문 사용)
그래서 코딩을 했는데
int main(int argc, char *argv[]) {
float modelyear, weight, fee;
int weightclass;
printf("model year와 weight 입력n");
scanf("%f%f",&modelyear,&weight);
if(modelyear<=2009&&weight<400)
weightclass=1;
else if(modelyear<=2009&&400<=weight<500)
weightclass=2;
else if(modelyear<=2009&&weight>=500)
weightclass=3;
else if(2009<modelyear<=2014&&weight<400)
weightclass=4;
else if(2009<modelyear<=2014&&400<=weight<500)
weightclass=5;
else if(2009<modelyear<=2014&&weight>=500)
weightclass=6;
else if(modelyear>=2015&&weight<450)
weightclass=7;
else if(modelyear>=2015&&weight>=450)
weightclass=8;
switch(weightclass)
{case 1:fee=45000;printf("model year weight weight class feen==============================n%f년%fkg%d%f",modelyear, weight, weightclass, feen);break;
case 2 : fee=55000;
printf("model yeartweighttweight classtfeen==============================n%f년t%fkgt%dt%f원n",modelyear, weight, weightclass, feen);break;
case 3 : fee=70000;
printf("model yeartweighttweight classtfeen==============================n%f년t%fkgt%dt%f원n",modelyear, weight, weightclass, feen);break;
case 4 : fee=80000;
printf("model yeartweighttweight classtfeen==============================n%f년t%fkgt%dt%f원n",modelyear, weight, weightclass, feen);break;
case 5 : fee=90000;
printf("model yeartweighttweight classtfeen==============================n%f년t%fkgt%dt%f원n",modelyear, weight, weightclass, feen);break;
case 6 : fee=105000;
printf("model yeartweighttweight classtfeen==============================n%f년t%fkgt%dt%f원n",modelyear, weight, weightclass, feen);break;
case 7 : fee=120000;
printf("model yeartweighttweight classtfeen==============================n%f년t%fkgt%dt%f원n",modelyear, weight, weightclass, feen);break;
case 8 : fee=150000;
printf("model yeartweighttweight classtfeen==============================n%f년t%fkgt%dt%f원n",modelyear, weight, weightclass, feen);break;
default: break;
}
return 0;
}
이렇게하니 switch문있는 줄에서 모든 프린트문에 stray''in progam, expected')' before n 이라는 에러가 나와서 검색해서 알아보니 어딘가 공백이 있으면 안된다는데 도무지 모르겠네요.
답변 미리 감사드립니다!