Advertisement

05.13.2007 at 07:38PM PDT, ID: 22569674
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Java program for Employee class variation

Tags: java, employee, program, class
To helpers,

This question is a practice exercise given to me in a begineers Java course.  The truth is, if I can get the code for this one, I will be able to work off it to help me with the review at the end of the chapter.   I have pretty much understood everything up to this point, but the material dealing with classes and methods has taken me for a loop.  Any help on this would be GREATLY appreciated.  

    Write a class Employee with the following specifications:
    Fields:
        Name - Name of employee
        Id - Employee id
        Salary - Employee salary
        Age - Employee age
        Position - Employee title

    Methods:
        1. getFedTax() - Returns (int) federal tax withheld. Computed as follows:
        multiply (salary - 800) by 17%.
        2. getSsTax(rate) - returns (int) social security tax withheld, rate% of salary;
        rate is int.
        3. getHealthFee(rate) - returns(int) health coverage employee contribution,
        rate% of salary; rate is int.
        4. getInsurance() - returns (int) employee contribution for insurance coverage.
        Amount of deduction is computed as follows:
        If the employee is under 40 rate is 3% of salary, if the employee is between
        40 and 50 rate is 4% of salary, and if the employee is between 50 and 60
        rate is 5% of salary. If the employee is above 60 the rate is 6% of salary.
        5. getNetPay() -returns (double) the net pay for the employee after deducting
        from salary, the deductions: ss(1), health(3), fed_tax() and insurance.

    Write an appropriate main class with a main() method to create two employee objects,
    and print information.
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: Sham850
Solution Provided By: alternation
Participating Experts: 2
Solution Grade: A
Views: 36
Translate:
Loading Advertisement...
05.13.2007 at 07:50PM PDT, ID: 19082744

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.17.2007 at 07:48AM PDT, ID: 19108617

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.17.2007 at 07:59AM PDT, ID: 19108719

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.17.2007 at 03:01PM PDT, ID: 19111929

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.19.2007 at 10:57PM PDT, ID: 19122366

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.13.2007 at 07:50PM PDT, ID: 19082744
We would certainly help you - but please share with us what you have come up so far. If you have not yet started writing the class, then I urge you to start asap with whatever understanding you have... anything! And we will gladly guide you in the best way you could finish it...

Hope that helps.
 
05.17.2007 at 07:48AM PDT, ID: 19108617
class Employee
{
    private int age;
    private int id;
    private int salary;
   
    private String name;
    private String position;
   
    public Employee(String name, int id, int salary, int age, String position)
    {
        this.name = name;
        this.id = id;
        this.salary = salary;
        this.age = age;
        this.position = position;
    }
   
    public int getFedTax()
    {
        //please note that rounding errors do occur here
        return (int)((salary-800)*0.17);
    }
   
    public int getSsTax(int rate)
    {
        //I'm unsure if you meant division or modulus in your question
        //this one assumes division:
        return (int)((rate/100)/salary);
        //if you meant modulus, comment the above and uncomment this:
        //return (int)(rate%salary);
        //once again, rounding errors will occur
    }
   
    public int getHealthFee(int rate)
    {
        //same code as getSsTax, really, so we could cheat and do:
        //return getSsTax(rate)
        //...but that would probably annoy whoever will be marking this. So:
        return (int)((rate/100)/salary);
        //once again, rounding errors will occur
    }
   
    public int getInsurance()
    {
        //once again, the same rounding errors
        if (salary<40)
            return (int)(salary*0.03);
        if (salary<50)
            return (int)(salary*0.04);
        if (salary<60)
            return (int)(salary*0.05);
        else
            return (int)(salary*0.06);
    }
   
    public double getNetPay()
    {
        //as the other methods return integers, I dont see the point of returning
        //a double...but hey, the assignment asks you to - *shrugs*
        return salary-getFedTax()-getSsTax(1)-getHealthFee(3)-getInsurance();
    }
}


class sham850sAssignment
{
    public static void main (String [] args)
    {
        Employee Fred = new Employee("Freddy", 1, 1000000, 22, "Garbage sanitisor");
        Employee Sarah = new Employee("Sarah", 1, 500000, 46, "<<Insert humorous profession name>>");
        System.out.println("Fred's Fex tax is: " + Fred.getFedTax());
        System.out.println("Fred's SS tax (rate of 1%) is: " + Fred.getSsTax(1));
        System.out.println("Fred's Health fee (rate of 3%) is: " + Fred.getHealthFee(3));
        System.out.println("Fred's insurance cost is: " + Fred.getInsurance());
        System.out.println("Fred's net pay is: " + Fred.getNetPay());
        System.out.println("---------------------------");
        System.out.println("Sarah's Fex tax is: " + Sarah.getFedTax());
        System.out.println("Sarah's SS tax (rate of 1%) is: " + Sarah.getSsTax(1));
        System.out.println("Sarah's Health fee (rate of 3%) is: " + Sarah.getHealthFee(3));
        System.out.println("Sarah's insurance cost is: " + Sarah.getInsurance());
        System.out.println("Sarah's net pay is: " + Sarah.getNetPay());
    }
}
 
05.17.2007 at 07:59AM PDT, ID: 19108719
Sorry I misread getSSTax and getHealthFee - they should multiply, not divide
 
05.17.2007 at 03:01PM PDT, ID: 19111929
Thank you for helpding with this.  I have been working with this code and found a couple things that seemed a little off.  When I rework the code reflect the 'of' in the getSsTax and getHealthFee,  multiplication, my numbers are huge.  For example, the above code tweaked to multiply, prints Health fee ( rate of 3%) is: 3000000 and my SS tax (rate of 1%) is: 1000000.  Any reason why these numbers are so big.  Also, when this is done, the net pay for both employees returns a negative number.  I see what you are saying about both the getSsTax and getHealthFee being the same code, but how do you distinguish between health coverage employee contribution and the social security tax withheld?  It seems if you use the same code, the same numbers would be used and produce strewed results.  Please let me know if I am reading into this too far.  I am really trying to learn this stuff.  Thank You Again---
 
05.19.2007 at 10:57PM PDT, ID: 19122366
The numbers are probably huge because you're not multiplying them correctly.

If you want 3% of 1000, to work it out you don't multiply 1000 * 3, do you? You do 0.03 * 1000 - hence why I did a division by 100 in some of the methods.

The net pay being negative would just be because the other methods are returning a large value.

The thing that makes getSSTax() and getHealthFee() different is that a user could, say, call getSSTax(3) and then call getHealthFee(5) - we're passing them different parameters to use in calculations, so they will return different values. If you were writing this yourself, it would be simpler to just make a method called, I don't know, say "getPercentage(int value)" that just takes a figure, works out the percentage tax based on that figure and returns it. Then just call it twice with different values. But the specifications ask you to make two, so I suppose you have to do it like that.

Hope this helps
Accepted Solution
 
 
20080236-EE-VQP-29