推介:| Web Hosting | 外賣系統 | Server colocation | Web Shop System | Makeup course |

查看完整版本: 想請問一下為何會計到4.1???

花之慶次 2008-3-3 22:25

想請問一下為何會計到4.1???

本來的答案是23.1, 但問題是程式是計出4.1....
public class DoubleDemo
{
    public static void main(String args[])
    {
       int i;
       double d;
       i=20;
       d=3.1;
       d=d+1;
       System.out.println("計算的結果是: " +d);
    }
}

出了什麼問題???

jayzhou_2046 2008-3-4 09:40

回復 #1 花之慶次 的帖子

d + 1是4.1沒錯.
d + i 才是23.1
頁: [1]
查看完整版本: 想請問一下為何會計到4.1???