public static String calculateDiscountPercent(Context context,double price,double discountPrice){
  int percent;
  if (discountPrice >= price) {
    percent=0;
  }
 else {
    percent=(int)Math.round(100 - ((discountPrice / price) * 100));
  }
  return String.format(context.getString(R.string.format_price_discount_percents),percent);
}

public static String calculateDiscountPercent ( Context context , double price , double discountPrice ) { int percent ; if ( discountPrice >= price ) { percent = 0 ; } else { percent = ( int ) Math . round ( 100 - ( ( discountPrice / price ) * 100 ) ) ; } return String . format ( context . getString ( R . string . format_price_discount_percents ) , percent ) ; }
method calculates the percentage discounts .
