#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    4
    Rep Power
    0

    [Homework] Monthly Pay ,problem with line spacing on printf


    I technically have 2 issues
    1)I do not know how to get the next line after my last name and Gross pay on the .txt file upon print.
    2. My net Pay is always a negative number

    Ways to fix my code are appreciated , point me in the direction where I am wrong.

    PHP Code:
    import javax.swing.JOptionPane;
    import java.io.*;
    import java.util.*;

    public class 
    Monthly_Paycheck {

        private static 
    double FederalIncomeTax 0.15;
        private static 
    double StateTax 0.035;
        private static 
    double SocialSecurityTax 0.057;
        private static 
    double MedicareTax 0.0275;
        private static 
    double PensionPlan 0.05;
        private static 
    double HealthInsurance 75;
        
        public static 
    void main(String[] argsthrows 
        FileNotFoundException
        
            
    {
            
    // declares and initializes the variables  Brad Wilkins
            
    double GrossAmt,Federal,State,SocialSecurity,Medicare,NetPay,Pension,Health;
            
            
    String EmployeeName;
            
    String inputStr;
            
    String outputStr;
            
            
    // Input 
            
    inputStr JOptionPane.showInputDialog ("Please enter the monthly gross amount: ");
    GrossAmt Double.parseDouble(inputStr);

    EmployeeName JOptionPane.showInputDialog ("Please enter the employee name:");

            
    Federal GrossAmt*(.15);
            
    State GrossAmt*( .035);
            
    SocialSecurity GrossAmt*(.0575);
            
    Medicare GrossAmt*(.0275);
            
    Pension GrossAmt*(.05);
            
    Health GrossAmt - (75);
            
    NetPay GrossAmt-Federal-State-SocialSecurity-Medicare-Pension-Health;
                    
        
            
    PrintWriter outFile = new PrintWriter("EmployeeMonthlyGross.txt");
            
    outFile.printf("Employees Name:" EmployeeName );
            
    outFile.printf("Gross Amount: %.2f %n"GrossAmt);
            
    outFile.printf("Federal Tax: %.2f %n"Federal);
            
    outFile.printf("State Tax: %.2f %n"State);
            
    outFile.printf("Social Security Tax: %.2f %n"SocialSecurity);
            
    outFile.printf("Medicare/Medicaid Tax: %.2f %n"Medicare);
            
    outFile.printf("Pension Plan: %.2f %n"Pension);
            
    outFile.printf("Health Insurance: %.2f %n"Health);
            
    outFile.printf("Net Pay: %.2f %n"NetPay);

            
    outFile.close(); 
            

        }


  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    My net Pay is always a negative number
    Print out the values of each of the variables subtracted from GrossAmt and see if their sum is greater than GrossAmt. For example: 10 - 6 - 6 is -2

    how to get the next line after my last name and Gross pay on the .txt file upon print.
    Sorry I do not understand the problem. Can you copy the program's output and paste it here and add some comments to it showing what is wrong and what it should be?

IMN logo majestic logo threadwatch logo seochat tools logo