为了对这个计算器进行有效地检验,设计了几组测试案例,测试结果如下:
Test No.
1
: (
1.11
)
=
1.110000
Test No.
2
:
1.11
+
2.22
-
3.33
*
4.44
/
5.55
=
0.666000
Test No.
3
:
1.11
+
(
2.22
-
3.33
)
*
4.44
/
5.55
=
0.222000
Test No.
4
:
1.11
+
(
2.22
-
3.33
)
*
(
4.44
+
5.55
)
/
6.66
=
-
0.555000
Test No.
5
:
1.11
*
((
2.22
-
3.33
)
*
(
4.44
+
5.55
))
/
(
6.66
+
7.77
)
=
-
0.852992
Test No.
6
: (
1.11
+
2.22
)
*
(
3.33
+
4.44
)
/
5.55
*
6.66
=
31.048920
Test No.
7
: (
1.11
-
2.22
)
/
(
3.33
+
4.44
)
/
5.55
*
(
6.66
+
7.77
)
/
(
8.88
)
=
-
0.041828
Test No.
8
: Error: (
1.11
+
2.22
)
*
(
3.33
+
4.44
: missing
")"
, please check your expression
Test No.
9
: Error: (
1.11
+
2.22
)
*
3.33
/
0
+
(
34
-
45
): divisor cannot be zero
Test No.
10
: Error:
12
+
89
^
7
: invalid character: ^
时间: 2024-10-28 23:06:48