Troubles with a Java Program

Icee WeinerIcee Weiner Regular
edited October 2011 in Tech & Games
Ok so here's the deal. I need to write a program that will calculate the monthly paycheck for an employee. I have it all written out and what not. The only thing I'm having trouble with is aligning the dollar sign with the total amount for each tax deduction. Here's what I have so far:
System.out.printf("Federal Income Tax: %11.2f\n", federalIncomeTax);
System.out.printf("State Tax: $%19.2f\n", stateTax);
System.out.printf("Social Security Tax: $%9.2f\n", socialSecurityTax);
System.out.printf("Medicare/Medicaid Tax: $%7.2f\n", medicareMedicaidTax);
System.out.printf("Pension Plan: $%16.2f\n", pensionPlan);
System.out.printf("Health Insurance: $%12.2f\n", healthInsurance);
System.out.printf("Net Pay: $%21.2f\n", netPay);
So what do I need to add so the dollar sign will align along with the number?


  • Icee WeinerIcee Weiner Regular
    edited October 2011
    Ok nevermind I figured it out. Delete thread please
  • Darth BeaverDarth Beaver Meine Ehre heißt Treue
    edited October 2011
    Care to share your solution perhaps?
  • SlartibartfastSlartibartfast Global Moderator -__-
    edited October 2011
    This is exactly what's wrong with most CS subjects.

    They teach you Java because it's on all the job listings, then you end up messing with strings for about an hour trying to get the damned things looking right.

    If i was ever in charge of an "intro to programming" class it'd teach C or C++ and put heavy emphasis on data structures and flow, at the end of the day that's what's important, not working around some weird quirk in the Java library.
  • edited October 2011
    For my intro to programming i learnt processing; which is a higher level java.

    Once you then have to learn normal java you understand much more about the data flow and can get right into something like C as well as actionscript and all the rest.
  • edited October 2011
    What's the point in deleting the thread? Just post the solution you used to fix your problem and maybe you'll help someone else out who has the same problem :)
Sign In or Register to comment.