java home work

profilesajeer
class_example_and_disscusion.docx

package bmarina;

import java.text.*;

public class EmployeeTester {

    public static void main(String[] args) {

        Employee emp1 = new Employee("Jim", "1234", "Terre Haute", "456-5789");

        System.out.println(emp1.tellAboutSelf());

        double wage = emp1.wage(40, 10);

        System.out.println(wage);

        double tax = emp1.tax(400.0, .20);

        System.out.println(emp1.tax(400.0, .20));

        System.out.println(emp1.tax(emp1.wage(40, 10), .20));

        NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();

        System.out.println("Wage is " + currencyFormat.format(wage));

        System.out.println("Tax is " +

                currencyFormat.format(emp1.tax(emp1.wage(40, 10), .20)));

        System.out.println("Tax is " + currencyFormat.format(tax));

        DecimalFormat decimalFormat = new DecimalFormat("##,##0.00");

        System.out.println("Tax is " + decimalFormat.format(tax));

        System.out.println("Random number " + decimalFormat.format(999123456.78912));

    }  

}

Add Comment

Employee New

Posted by  Ayman Abuhamdieh  at Tuesday, November 12, 2013 3:12:17 PM EST

//Written by Ayman

package bmarina;

public class Employee {

    //attributes

    private String name;

    private String IDNo;

    private String address;

    private String phoneNo;

   

    //parameterized constructor

    public Employee(String newName, String newIDNo, String newAddress,

            String newPhoneNo){

        setName(newName);

        setIDNo(newIDNo);

        setAddress(newAddress);

        setPhoneNo(newPhoneNo);       

    }

    //wage method

    public double wage(double hoursWorked, double ratePerHour) {

        double pay = hoursWorked * ratePerHour;

        return pay;

    }

    // tax method, tax rate should be a percentage

    public double tax(double aWage, double taxRate){

        double taxAmount = aWage * taxRate;

        return taxAmount;

    }

    // setter methods

    public void setName(String aName) {

        name = aName;

    }

    public void setIDNo(String anIDNo) {

        IDNo = anIDNo;

    }

    public void setAddress(String anAddress) {

        address = anAddress;

    }

    public void setPhoneNo(String aPhoneNo) {

        phoneNo = aPhoneNo;

    }

    //getter methods

    public String getName() {

        return name;

    }

    public String getIDNo() {

       return IDNo;

    }

    public String getAddress() {

       return address;

    }

    public String getPhoneNo() {

       return phoneNo;

    }

   

    public String tellAboutSelf() {

        String info = "Employee name is " + getName() + ", \nID# is " + getIDNo()

            +", \naddress is " + getAddress() + " \nand phone# is " + getPhoneNo();

        return info;

    }

}