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

Thread: Whats wrong with my code

  1. #1
    Junior Member Siboniso Ndlovu's Avatar
    Join Date
    Feb 2014
    Posts
    8
    My Mood
    Bored
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Whats wrong with my code

    Public class Employee
    {
    private String empno;
    private String name;
    private String title;
    private double sal;

    public employee()
    {
    empno = "";
    name = "";
    title = "";
    sal =0;
    }
    public employee(String empno, String name, String title, double sal)
    {
    this.empno = empno;
    this.name = name;
    this.title = title;
    this.sal =sal;
    }
    Public void newsal()
    {
    if(sal>50000)
    sal = sal +(sal*0.03);
    else if(sal >=25000 )
    sal = sal + (sal*0.05);
    else
    sal = sal +(sal*0.07)
    }
    public string getempno()
    {
    return empno;
    }
    public string getname()
    {
    return name;
    }
    public string gettitle()
    {
    return title;
    }
    public double getsal()
    {
    return sal;
    }
    Public void replace(string title)
    {
    this.title = title;
    }
    }

    public static final int num=300;
    public static void main(String[]args)
    {
    Employee[]emp = new Employee[num];
    input (emp);
    increase(emp);
    change(emp);
    display(emp);
    }
    public static void(Employee[]emp)
    {
    for(int x = 0;x<num;x++)
    {
    string temp = JOptionPane.showInputDialog(null,"Please enter employee number")
    string temp1 = JOptionPane.showInputDialog(null,"Please enter employee name")
    string temp2 = JOptionPane.showInputDialog(null,"Please enter employee title")
    string temp3 = JOptionPane.showInputDialog(null,"Please enter employee salary")
    double sal = Double.parseDouble(temp3);

    emp[x] =new Employee(temp,temp1,temp2,sal);
    }
    }
    public static void increase(Employee[]emp)
    {
    for(int x =0;x<num ;x++)
    {
    if(emp[x].gettitle().equalsIgnoreCase("technicain") ;
    emp[x].newsal();
    }
    }
    public static void change(Employee[]temp)
    {
    for(int x =0;x<num ;x++)
    {
    if(emp[x].gettitle().equalsIgnoreCase("Secretary")
    emp[x].gettitle()="Office Adminstrator";
    }
    }
    public static void display(Employee[]emp)
    {
    System.out.print("EmpNo"+"Name"+"Title"+"Salary(R) "+"\t")
    for(int x =0; x<num; x++)
    {
    System.out.println(emp[x].getempno()+emp[x].getname()+emp[x].gettitle()+emp[x].getsal+"\t");
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Whats wrong with my code

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    Please explain.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. whats wrong with my code
    By abhi1402 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 6th, 2013, 09:17 AM
  2. hi if u can help me please whats wrong with this code
    By ohad in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 8th, 2013, 02:04 PM
  3. Can anyone see whats wrong with this code
    By javapol in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 27th, 2013, 03:59 PM
  4. whats wrong with my code.
    By jove in forum Object Oriented Programming
    Replies: 3
    Last Post: July 30th, 2011, 11:45 PM
  5. Whats wrong with my code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 4th, 2011, 05:34 PM