割引計算アプリを作っているのですが、支払金額の金額の部分を整数にしたいのですがどうすれば整数にできますか?
全部だとコードが結構長くなるので、割引率からのコードを載せときます。
まだ始めたばかりの初心者なので、コードが変だっとり、ごちゃごちゃしていると思いますが回答の方宜しくお願いしますm(_ _)m
java
1 class SeekBarControl implements SeekBar.OnSeekBarChangeListener { 2 3 private int discount = 0; 4 5 @Override 6 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 7 TextView text = (TextView)findViewById(R.id.txtDiscount); 8 discount = progress * 5; 9 text.setText(String.valueOf(discount + "%")); 10 } 11 12 13 14 @Override 15 public void onStartTrackingTouch(SeekBar seekBar) { 16 17 } 18 19 20 21 @Override 22 public void onStopTrackingTouch(SeekBar seekBar) { 23 24 Toast.makeText(MainActivity.this, discount + "%の割引をします",Toast.LENGTH_SHORT).show(); 25 26 27 TextView price = (TextView)findViewById(R.id.txtprice); 28 double priceDouble = Double.parseDouble(price.getText().toString()); 29 30 31 double payInt = priceDouble - (priceDouble * ((double) discount/100d)); 32 33 Toast.makeText(MainActivity.this, discount + "%の割引をします 結果は" + payInt 34 + "円です", Toast.LENGTH_SHORT).show(); 35 36 37 TextView pay = (TextView)findViewById(R.id.txtPay); 38 pay.setText(String.valueOf("¥ " + payInt)); 39 40 41 } 42 }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。