int 대선배, 형님, 누님 // (꾸벅).
cout << \"도형면적 구하는 심플 프로그램 짜봤는데 소수점 넣으면 에러뜨네요\";
cout << \"이거 어떻게 고쳐야하나요?\".
cin >> 대선배, 형님, 누님;
cout << \"가르켜주세요.\";
/* 프로그램은 영어로 되어있는데 횽들수준이면 문제없을꺼야.
그래도 이해안가는부분있으면 한글로 고쳐놓을께. 부탁해요
*/
#include <iostream>
using namespace std;
int main()
{
int length, width, area, area2 ; // 4 ints to hold measurement
/* area is in square feet
area2 is in square yards
*/
cout << \"How long is the piece of land <in feet>? \";
cin >> length; // get measurement in ft.
cout << \"How wide is the piece of land <in feet>? \";
cin >> width;
area = length * width;
area2 = area / 9;
cout << \"The lot has an area of \" << area << \" square feet, which is \" << area2 << \" square yards.\" << endl;
return 0;
}
//교정후, 관점은 int 에서 double length, width, area, area2 로 고치는것
#include <iostream>
using namespace std;
int main()
{
double length, width, area, area2 ; // 4 ints to hold measurement
/* area is in square feet
area2 is in square yards
*/
cout << \"How long is the piece of land <in feet>? \";
cin >> length; // get measurement in ft.
cout << \"How wide is the piece of land <in feet>? \";
cin >> width;
area = length * width;
area2 = area / 9;
cout << \"The lot has an area of \" << area << \" square feet, which is \" << area2 << \" square yards.\" << endl;
return 0;
}
관건은 length 에 51.5
width에 125.75 를 넣어야하는데 소수를 넣으면 바로 에러뜨네요
int대신 다른 자료형을 찾아봐. 힌트얌
double 사용하는거 같은데.. 이럴땐 어덯게 double 사용하죠?
변수선언할때 int를 왜 썼는지 잘 생각해보고 어떻게 고쳐야 할지 응용해보면 되겠당.
double main()
double length, width, area, area2
이렇게했는데.. 더블 이렇게 쓰는게 아닌가봐요. 힝 ㅜㅜ
네이버 검색해야겟따 ㅜㅜ
원하는건 변수가 소수형태의 값을 가지는거지 main 함수가 소수형태의 리턴값을 가지는게 아니잖아여. 책을 펴고 자료형 부분을 읽어보세요.
The lot has an area of 6476.13 square feet, which is 719.569 square yards.
Minryu 형 고마워요 고친거같아요.. 글 수정해놨어요.. 나중에 저같은 사람있으면 와서 보라고 ㅋㅋ
글구 main에 double써도 나오긴 나오는데 뭐가 오류나는거지? lol 무슨 에러인지 써보세요
뿌잉뿌잉 형 고마워요, main의 개념이없었어요. 형말듣고 다시한번 교과석 읽었더니 이해가 가네요 ㅎㅎㅎ
혹시나해서 쓰는데, 주석도 고치는거 까먹지말고. 4 ints to hold measurement. 왠지 미국대학에서 봄학기듣는 사람의 숙제일것같아
Minryu 형 센스있네요 ㅎㅎㅎㅎㅎㅎ 고마워요 프겔횽들