Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Beauty School student taking JAVA? doesn't work out so well, NEED HELP!

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Beauty School student taking JAVA? doesn't work out so well, NEED HELP!

    So I am taking this Java Programming class for my last 4 credits of my bachelor's degree and i'm also full-time in beauty school. I have put about 20 Hours into this assignment and I CANNOT get it . Someone please help! There is a .dat file that was given to us, not sure how to upload it here? I could send it through e-mail if you can help me. Any help would be greatly appreciated! This was due yesterday and I was given an extension until tomorrow. Here is the problem given to us and here is what I have written..

    Here is the problem definition.
    Your employer needs a program that calculates and prints the monthly paycheck for an employee. The net pay is calculated after taking the following deductions:
    Federal Income Tax 15%
    State Tax 3.5%
    Social Security Tax 5.75%
    Medicare/Medicaid Tax 2.75%
    Pension Plan 5%
    Health Insurance $75.00
    Your program will read the data from a file, paycheck.dat, that is attached to this assignment.
    The data file contains the following data: first name, last name, annual salary (the company pays it's staff every month; so there are 12 pay periods in a year)

    The format for the data file is:
    Allison Neilds 92950.00
    Please note: In a normal business, you would have multiple records in your data file one for each employee; but since we have not covered loops yet we can only read one employee... it is a start!
    The output will contain: first name, last name, monthly gross pay, federal taxes, state taxes, SSN taxes, Medicare/Medicaid Taxes, Pension, Health Insurance, Net Pay
    A sample output follows:

    Allison Neilds 7745.83 1161.88 271.10 445.39 213.01 387.29 75.00 5192.17
    Some Processing Requirements:
    - use the Scanner/FileReader or Scanner/BufferedReader to read the data into your program.
    - put the paycheck.dat file in the directory of where your program is located and use a relative pathname to reference the file in the program.
    - use the PrintWriter to create the output file, name it paycheckout.dat.- use a relative pathname to reference the output file.

    - String.format to format the the output to 2 decimal places.
    - remember the output is producing a data file, not a report do not use $ or commas
    - Do not use magic numbers! A magic number is a numeric constant embedded in code, without a constant definition. Any number except -1, 0, and 1 is considered magic.
    - use the try/catch statement to catch the FileNotFoundException and IOException
    Click on the link below to submit for grading, submit the unit6_YourLastName.java program.
    Be sure to put your name in the comment box.
    DO NOT email the assignment to me.




    /* Program Name: unit6_mihans.java

    */

    import java.io.*;
    import java.util.*;

    public class unit6_mihans
    public static void main(String args[]) throws IOException

    String firstName;
    String lastName;
    double annualPay;
    double monthlyPay;
    double federalTax;
    double stateTax;
    double socialSecurity;
    double medicareMedicaid;
    double pensionPlan;
    double healthInsurance;
    double netPay;

    Scanner inFile = new Scanner(new FileReader("paycheck.dat"));

    while (inFile.has Next())
    {
    String firstName=inFile,next();
    String lastName=inFile.next();
    annualPay=inFile.nextDouble();

    if (inFile.hasNextDouble())
    {
    monthlyPay= annualPay/12;
    federalTax= monthlyPay *.15;
    stateTax= monthlyPay * .035;
    socialSecurity= monthlyPay * 5.75;
    medicareMedicaid= monthlyPay * 2.75;
    pensionPlan= monthlyPay * .05;
    healthInsurance= 75.00;
    netPay= monthlyPay - federalTax - stateTax - socialSecurity - medicareMedicaid - pensionPlan - healthInsurance;

    String outputString=String.format("%25s\n",lastName +","+firstName) + String.format("%25s %7.2f%n",+monthlyPay","+federalTax","+stateTax","+ socialSecurity","+medicareMedicaid","+pensionPlan" ,"+healthInsurance","+netPay);

    PrintWriter pw = new PrintWriter(System.out, true);
    pw.println(outputString);
    }
    catch (FileNotFoundException e)
    {
    outputString=String.format("%25s\n",lastName + "," +firstName)
    + String.format
    System.out.println(outputString);
    }
    String filename = ("paycheck.dat");
    try
    {
    new File(filename).createNewFile();
    }
    catch (IOException e) {
    System.out.println("Unable to create "+filename+" : "+e.getMessage());
    }
    inFile.close();
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,267
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: Beauty School student taking JAVA? doesn't work out so well, NEED HELP!

    It help to actually ask a question...posting an assignment with the code you have written gives us little direction as far as where you are having problems (see the getting help link in my signature, and please use the code tags it describes)

  3. The Following User Says Thank You to copeg For This Useful Post:

    KevinWorkman (October 20th, 2011)

  4. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,298
    My Mood
    Hungover
    Thanks
    142
    Thanked 620 Times in 531 Posts

    Default Re: Beauty School student taking JAVA? doesn't work out so well, NEED HELP!

    In addition to what copeg told you, you might also want to give this a read-through: How to Program (stuck on homework? READ THIS BEFORE POSTING)

    Edit- Hey look, my 2000th post. Neat.
    Last edited by KevinWorkman; October 20th, 2011 at 08:00 AM.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. School Java Project Help (XML and links)
    By MC2170 in forum Java Theory & Questions
    Replies: 6
    Last Post: July 3rd, 2012, 08:44 AM
  2. [SOLVED] Taking a square root in Java, answer appears as 0.0. Why?
    By r19ecua in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 30th, 2012, 10:47 AM
  3. Student.java
    By ruffu054 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 12th, 2011, 02:40 PM
  4. Hello to all!/Java Student.
    By Benjamin Cainan in forum Member Introductions
    Replies: 1
    Last Post: May 3rd, 2011, 09:48 AM
  5. School java project, completely stuck
    By John1818 in forum Java Theory & Questions
    Replies: 0
    Last Post: November 18th, 2010, 03:10 AM