J'essaie d'utiliser le code suivant pour produire un nombre décimal, mais l'évaluation de l divisé par h (bas par haut) sort toujours pour être 0.Comment faire 100 divisé par 110 égale une décimale en Java/Android
Comment puis-je corriger cela? Merci!
EditText marketValLow = (EditText) findViewById(R.id.marketValLow);
EditText marketValHigh = (EditText) findViewById(R.id.marketValHigh);
String valLow = marketValLow.getText().toString();
String valHigh = marketValHigh.getText().toString();
int l = Integer.parseInt(valLow);
int h = Integer.parseInt(valHigh);
if (valLow.trim().equals("") || valHigh.trim().equals("")) {
Toast.makeText(CurrentMarketValue.this, "You need to enter a high AND low." + valLowIndex, Toast.LENGTH_SHORT).show();
} else if ((l/h) < .9) {
Toast.makeText(CurrentMarketValue.this, "The range between your value cannot be more than 10%." + (l/h), Toast.LENGTH_SHORT).show();
}
Btw, le sujet et le code ne correspondent pas. Dans le code vous avez un ratio de 9/10, dans le sujet vous avez un ratio de 100/110 ou 10/11, ce qui est proche, mais pas la même chose. –