I have already searched but nothing is working so i asked. I'm dividing two textviews and getting the o/p in another textview. The problem is i'm getting the answer in decimals. I want to limit the number after decimal to only one. htlAvg is the o/p textview. Thank you!
My code:
totalCount = jsonObject.getString("counts");
//Toast.makeText(hotel_reviews.this, ""+totalCounts, Toast.LENGTH_SHORT).show();
htlStr.setText(totalStars);
htlCnt.setText(totalCount);
try {
float a = Float.valueOf(htlStr.getText().toString());
int b = Integer.valueOf(htlCnt.getText().toString());
float c = (float) a / (int) b;
htlAvg.setText(String.valueOf(c));
// Toast.makeText(hotel_reviews.this, "" + c, Toast.LENGTH_SHORT).show();
} catch (NumberFormatException e) {
Toast.makeText(hotel_reviews.this, "", Toast.LENGTH_SHORT).show();
}