Code example for DecimalFormat

Methods: format, setMinimumFractionDigits

0
		if(this.round.isChecked()){
			notRoundedTip = Math.round(notRoundedTip);
			finalTip = Integer.toString((int)notRoundedTip);
		} 
		else{ 
			DecimalFormat df = new DecimalFormat("#.##");
			df.setMinimumFractionDigits(2);
			finalTip = df.format(notRoundedTip);
		} 
		 
		this.tip.setText("$"+finalTip);
	} 
	 
 
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present. 
		getMenuInflater().inflate(R.menu.activity_tip_calculator, menu);
		return true; 
	}