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

Thread: help to create a class

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question help to create a class

    hello everyone, it's my first time on this site, i need help cause i get errors and i don't have solutions in the book for the following exercise:

    Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test application named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again.

    thanks for any help!

    best regards


  2. #2
    Junior Member
    Join Date
    Dec 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question help to create a class


    i found the following exercise but i can't make it work and get errors besides i don't have solutions in my book:

    Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test application named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again.

    thanks for any help!

    best regards

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question help to create a class


    i tried to do the following exercise but i get errors and i don't have solutions in my book:

    Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test application named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again.

    thanks for any help!

    best regards

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,301
    My Mood
    Mellow
    Thanks
    252
    Thanked 777 Times in 762 Posts

    Default Re: help to create a class

    Here's a tip: Don't post duplicate posts. It doesn't get you help any sooner, causes confusion, and puts you in a bad light.

    Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers.

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    11
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: help to create a class

    How are we supposed to help if you don't tell uw what errors you get? :p
    And it'll help if you post your current source

  6. #6
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help to create a class

    hii....the code below can solve your problem...
    ...
    Last edited by copeg; December 30th, 2013 at 12:18 AM. Reason: removed spoonfeeding

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: help to create a class

    @KotiChowdary, please read the anoucement at the top of every form, and please read The Problem with Spoon-feeding

  8. #8
    Junior Member
    Join Date
    Dec 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help to create a class

    sorry! i will do better next time!




    Quote Originally Posted by GregBrannon View Post
    Here's a tip: Don't post duplicate posts. It doesn't get you help any sooner, causes confusion, and puts you in a bad light.

    Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers.

Similar Threads

  1. Create class diagram.
    By Shareefuddin in forum Java IDEs
    Replies: 1
    Last Post: April 24th, 2013, 08:59 AM
  2. create a test class (main method) to start(run) the class in Java
    By curious725 in forum Java Theory & Questions
    Replies: 5
    Last Post: August 1st, 2012, 04:21 AM
  3. Can't create inner class object outside the outer class help needed?
    By Dark knight in forum Java Theory & Questions
    Replies: 2
    Last Post: July 31st, 2012, 03:34 AM
  4. In a class create an array list of elements of another class, help!
    By LadyBelka in forum Collections and Generics
    Replies: 3
    Last Post: May 4th, 2011, 06:00 PM
  5. Replies: 2
    Last Post: January 22nd, 2011, 11:20 PM