게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
java 자바 완전 기초 도와주세요...
게시물ID : computer_57421짧은주소 복사하기
작성자 : 레드a
추천 : 0
조회수 : 269회
댓글수 : 3개
등록시간 : 2012/08/27 08:43:03


public class Problem9 {


public static void main(String[] args) {

// TODO Auto-generated method stub


double w = 4.5;

double h = 7.9;

double area = w * h;

double perimeter = 2 * (w + h);

System.out.println("The area of a rectangle with the width of " + w + " and height of " + h + " is " + area + ".");

System.out.println("The perimeter of a rectangle with the width of " + w + " and height of " + h + " is " + perimeter + ".");

System.out.println(area);

System.out.println(4.5 * 7.9);

}


}


이렇게 하고 런 하면


The area of a rectangle with the width of 4.5 and height of 7.9 is 35.550000000000004.
The perimeter of a rectangle with the width of 4.5 and height of 7.9 is 24.8.
35.550000000000004
35.550000000000004

이렇게 뜨는데 왜  

7.9*4.5 가 35.550000000000000004 로 나오나요 ㅠㅠ??

35.55 라고 나와야 되는거 아닌가요?>?

0.0000000000004 는 어디서 갑툭튀 하는건지 모르겟네요;;




전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호