質問編集履歴

1

コードの挿入

2022/06/04 09:02

投稿

Kousukee
Kousukee

スコア2

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,31 @@
1
+ ```Java
2
+ class Sample7_2 {
3
+ public static void main(String[] args) {
4
+ Item i1 = new Item();
5
+ i1.taxShow("ガム",100,90,10);
6
+ }
7
+ }
8
+
9
+ class Item{
10
+ private int num;
11
+ private int price;
12
+ private String name;
13
+
14
+ private void buyShow() {
15
+ System.out.println(" 商品Nо.は " + num + " です。");
16
+ System.out.println("   商品名 " + name + " です。");
1
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-06-04/6fd0fccd-e572-4533-8819-1b8a38de6b5a.jpeg)
17
+ System.out.println("  商品価格 " + price + "円 です。");
18
+ }
19
+
20
+ public void taxShow( String name, int num, int price, int tax) {
21
+ buyShow();
22
+ int tvalue = price + (price * (tax/100));
23
+ System.out.println("   消費税 " + tax + " %です。");
24
+ System.out.println("税込商品価格 " + tvalue + " 円です。");
25
+ }
26
+ }
27
+
28
+ ```
2
29
 
3
30
  ————-—-実行結果————————
4
31
  商品No.は 0 です。