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 5 of 5

Thread: please could you help me with this java problem im very lost

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile please could you help me with this java problem im very lost

    Hi everyone could you help me with my java problem my prof got this in a seat-work but i really don't know how to solve this java problem please help me and also i got 0 over 100 in my seat-work please kindly help me step by step
    on how to solve this java problem

    Write a program that will calculate the income of an employee an employee is either a part-time employee or a full-time employee.get 1 represents a part-time employee and 2 represents a full-time employee. A full time employee and part-time employee regular member of hours work in a week is 40 number of hours worked that exceeds regular number of hour rate is 40.00 dollar while fast-time employees hour rate 15% of hourly rate multiplied by the number of overtime hours. the overtime pay should be computed if and only if the overtime hours rendered is not zero

    please could you help me im really confused with this problem please help me
    i really need help badly please


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: please could you help me with this java problem im very lost

    Is it the Java you need help with or the maths?

    // Json

  3. #3
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Smile Re: please could you help me with this java problem im very lost

    i dont exactly get the case scenario that you have posted.

    --the 40.00 dollar additional rate for any exceeding hours , im not sure if it will be multiplied for any
    overtime hours

    anyway.
    is this what you want

    package xTestPackagex;
     
    import java.io.*;
     
    /**
     *
     * @author Administrator
     */
    public class Employee {
     
        private static BufferedReader br = new BufferedReader(
                                           new InputStreamReader(System.in));
     
        public static void main(String[] args)throws IOException {
     
            //constant for the maximum hours
            final int MAX_HOURS = 40;
            //constant for the overtime payment
            final double ADDITIONAL_PAYMENT = 40.00;
            //constant for the percentage of the added rate for the fast time
            //employees
            final double FAST_TIME_RATE = 0.15;
     
            int employeeType,
                exceedingHours,
                workingHours;
     
            double regularRate,
                   overTimeRate,
                   grossPay,
                   grossPayForFastTime;
     
            double fastTimeTotalGrosspay;
     
            double totalGrossPay;
     
     
            System.out.print("Enter The Type Of The Employee: ");
            employeeType = Integer.parseInt(br.readLine());
     
            /**
             *base on the scenario there are two numerical representation of
             * employees 1 for part time and 2 for full time ,
             * so i wrote a switch statement
             */
            /* I also added a numerical representaion of the fast time employees
             *  because the scenario gives another type of employee
             */
     
            switch(employeeType) {
     
                //case 1 for part Time employee
                case 1:
                    System.out.println("");
                    System.out.println("Part Time Employee");
                    System.out.println("");
     
                    /**
                     * I added an Input value to get the regular rate for
                     * each type of employee, because the scenario didnt give
                     * any given value for the regular salaray for each type
                     * of employee
                     */
                    System.out.print("Enter Regular Rate For Part Time " +
                                     "Employee: ");
                    regularRate = Double.parseDouble(br.readLine());
     
                    System.out.print("Enter Working Time: ");
                    workingHours = Integer.parseInt(br.readLine());
     
                    if (workingHours > MAX_HOURS) {
     
                        exceedingHours = workingHours- MAX_HOURS;
                        overTimeRate = ADDITIONAL_PAYMENT * exceedingHours;
                        grossPay = regularRate * MAX_HOURS;
                        totalGrossPay = grossPay + overTimeRate;
     
                        System.out.println("Total Gross Pay For This Part Time " +
                                           "Employee Is: " + totalGrossPay);
                    }
                    else if (workingHours == MAX_HOURS) {
     
                        totalGrossPay = regularRate * workingHours;
     
                        System.out.println("Total Gross Pay For This Part Time " +
                                           "Employee Is: " + totalGrossPay);
                    }
     
                    break;
     
                //case 2 for full time
                case 2:
                    System.out.println("");
                    System.out.println("Full Time Employee");
                    System.out.println("");
     
                    //Same here.
                    System.out.print("Enter Regular Rate For Full Time " +
                                     "Employee: ");
                    regularRate = Double.parseDouble(br.readLine());
     
                    System.out.print("Enter Working Time: ");
                    workingHours = Integer.parseInt(br.readLine());
     
                    /*condition to get the overtime rate */
                    if (workingHours > MAX_HOURS) {
     
                        exceedingHours = workingHours - MAX_HOURS;
                        overTimeRate = ADDITIONAL_PAYMENT * exceedingHours;
                        grossPay = regularRate * MAX_HOURS;
                        totalGrossPay = grossPay + overTimeRate;
     
                        System.out.println("Total Gross Pay For This Full Time " +
                                           "Employee Is: " + totalGrossPay);
                    }
                    else if (workingHours == MAX_HOURS) {
     
                        totalGrossPay = regularRate * workingHours;
     
                        System.out.println("Total Gross Pay For This Full Time " +
                                           "Employee Is: " + totalGrossPay);
                    }
     
                    break;
     
                //case 3 for fast time
                case 3:
                    System.out.println("");
                    System.out.println("Fast Time Employee");
                    System.out.println("");
     
                    //Same here.
                    System.out.print("Enter Regular Rate For Fast Time Employee: ");
                    regularRate = Double.parseDouble(br.readLine());
     
                    System.out.print("Enter Workig Hours: ");
                    workingHours = Integer.parseInt(br.readLine());
     
                    /*Condition for any exceeding hours */
                    if (workingHours > MAX_HOURS) {
     
                        exceedingHours = workingHours - MAX_HOURS;
                        overTimeRate = (FAST_TIME_RATE * regularRate)
                                        * exceedingHours;
                        grossPay = regularRate * MAX_HOURS;
                        totalGrossPay = grossPay + overTimeRate;
     
                        System.out.println("The Total Gross Pay For Fast Time " +
                                         "Employees Is: " + totalGrossPay);
                    }
                    /*
                     *if the working hours is exactly the maximum hours
                     *it will get the normal grosspay
                     */
                    else if (workingHours == MAX_HOURS) {
     
                        totalGrossPay = regularRate * MAX_HOURS;
     
                        System.out.println("The Total Gross Pay For Fast Time " +
                                           "Employees Is: " + totalGrossPay);
                    }
            }
     
        }
    }


  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: please could you help me with this java problem im very lost

    Hello eyeore. Welcome to the Java Programming Forums

    I think this question has already been answered in another thread. I'll see if I can find it.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  5. #5
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: please could you help me with this java problem im very lost

    Does this thread help you?

    http://www.javaprogrammingforums.com...lp-please.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. java problem
    By Mj Shine in forum Java Theory & Questions
    Replies: 1
    Last Post: August 14th, 2009, 12:24 AM
  2. Java session problem
    By Padmaja in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: August 5th, 2009, 09:06 PM
  3. [SOLVED] Error "TitleChanger is abstract; cannot be instantiated"
    By Uzual in forum AWT / Java Swing
    Replies: 2
    Last Post: May 26th, 2009, 11:23 AM
  4. Java GUI problem in paintComponent?
    By Richard_ in forum AWT / Java Swing
    Replies: 2
    Last Post: May 1st, 2009, 08:19 AM
  5. [SOLVED] JAVA JList Problem in visual images
    By antitru5t in forum AWT / Java Swing
    Replies: 4
    Last Post: April 15th, 2009, 03:09 PM