I have problem formating this code to displey 2 decimal points

public String toString() 
      {
         return super.toString() + "\n\tYear Level:\t" + getYearLevel() + "\n\tTuition:\t$" + "%1$.2f",calcTuition();
      
      }

calcTuition is type double

how can I do this?

Thanks

public String toString() 
      {
         return super.toString() + "\n\tResearch Area:\t" + getResearchArea() + "\n\tTuition:\t$" + String.format("%.2g%n", calcTuition());
      
      }

like that I get number like ; $7.2e+03
dont get it?

got it :D

But can some tell me where can I find more info about it?

public String toString() 
      {
         return super.toString() + "\n\tYear Level:\t" + getYearLevel() + "\n\tTuition:\t$" + String.format("%.2f%n", calcTuition());
      
      }

Edited 4 Years Ago by mehnihma: n/a

This question has already been answered. Start a new discussion instead.