質問編集履歴
1
ソースコードの書きかた、調べた後のコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
public class Kadai1 {
|
35
|
+
```public class Kadai1 {
|
36
36
|
|
37
37
|
public static void main(String[]args){
|
38
38
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
}
|
58
58
|
|
59
|
-
}
|
59
|
+
}```
|
60
60
|
|
61
61
|
|
62
62
|
|
@@ -64,4 +64,32 @@
|
|
64
64
|
|
65
65
|
|
66
66
|
|
67
|
-
intをdoubleに変換する方法を調べて
|
67
|
+
intをdoubleに変換する方法を調べ、下記のようにコードを変えてみました
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
```public class Kadai1 {
|
72
|
+
|
73
|
+
public static void main(String[]args){
|
74
|
+
|
75
|
+
int nedan=2000;
|
76
|
+
|
77
|
+
double Tax=10/100;
|
78
|
+
|
79
|
+
int result;
|
80
|
+
|
81
|
+
result=tax(nedan,Tax);
|
82
|
+
|
83
|
+
System.out.println(nedan+"の商品の税込価格は"+(nedan+result)+"円(消費税は"+result+"円)です。");
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
public static int tax(int nedan,int Tax){
|
88
|
+
|
89
|
+
(int) result=nedan*Tax;
|
90
|
+
|
91
|
+
return result;
|
92
|
+
|
93
|
+
// }
|
94
|
+
|
95
|
+
}```
|