Results 1 to 7 of 7
  1. #1
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Question Help me Please??

    I am trying to create a compensation report for employees based on an earned commission credit offered by the firm that is determined by annual sales percentages, and I am supposed to call two separate classes, on separate files to accomplish this.... I have managed to work out the compensation formula, and it does display the correct amounts based on the commission curve, but I am having serious issues getting to include the second class, because no matter what I try, I keep getting an error requesting for me to create a class for any variables that I import from the other class. Here is the code from what I have so far:
    Java Code:
    /*Zachariah A Lloyd*/
    package newcommissions;
    import java.util.Scanner;
    public class NewCommissions {
       public static double main(String[] args) {
            Scanner input = new Scanner (System.in); //obtains input
            double sales; // annual sales total
            double commission = 0;// rate of commission
            double pay;// pay including commision bonus
            System.out.println ("This program computes commission bonuses, based on annual sales.");
            System.out.print ("Please enter yearly sales total: $");
            sales = input.nextDouble(); //user prompt
           if (sales >= 80000) { // user input
               commission = 0.05;} //Applies commission bonus }
            if (sales >= 100000) {
               commission = 0.0625;}	
            if (sales < 80000) {
               commission = 0; }        
            pay = ((sales * commission) + 50000); // commission bonus added
            return commission;
       }}
    and this does what it is supposed to.... It compiles, runs, and returns the desired values to the user, but for the life of me I cannot figure out how to add a second class to this, despite watching numerous tutorials showing how it is done.
    For the record, I am experiencing my disappointments in NetBeans 7.2

    I have tried the method I have been shown, of going to the source package, newcommissions and right clicking to create a new Java class, but it will not let me do even the simplest operations in this class I create. As below:
    Help me Please??-cannot-make-class.jpg
    and then, if I try to run this it gives me this gem:
    Help me Please??-nomainz.jpg

    But I thought the main was in the initial class file, NewCommissions:
    Help me Please??-there-main.jpg
    and I am trying to use both classes together, but NetBeans is not having it for some reason??
    If anyone can help me and tell me what I am doing wrong, I will be eternally grateful!!

  2. #2
    phyzix5761 is offline Member
    Join Date
    Nov 2012
    Posts
    43
    Rep Power
    0

    Default Re: Help me Please??

    I'm pretty new at this stuff but I don't think a class can return something that way. You would have to create a function that returns an int, create an instance of that object where you want to use it, and then call the function to return the value.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: Help me Please??

    Please go through the Forum Rules -- particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    zlloyd1 is offline Member
    Join Date
    Nov 2012
    Posts
    57
    Rep Power
    0

    Default Re: Help me Please??

    Quote Originally Posted by DarrylBurke View Post
    Please go through the Forum Rules -- particularly the third paragraph.

    db
    I apologize, but I did not recall that guideline, my mistake!!

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: Help me Please??

    Continued here: Need to create or set main class for project

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •