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

Thread: Why am I getting a <No Main Classes Found> error message?? Help please!!

  1. #1
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Why am I getting a <No Main Classes Found> error message?? Help please!!

    I have been working on this program to calculate a sales commission and failing miserably. I need to get this program working so I can then modify it to add an array to calculate and compare the sales info for 2 sales people. And it's all due Monday!!

    Someone PLEASE take a look at this code and tell me how to fix it. I am at my wits end here.

    Thanks in advance for your help!!

    package compensation;
    import java.text.DecimalFormat;
    import java.util.Scanner;
     
    /**
     * @author Rick Sebastian
     */
     
    public class Compensation 
    {
        public static double main(String[] args) 
        {        
            int salary = 60000;  //Defines base salary of $60K
            double targetSales = 120000; //Defines the target sales object to determine commission
            double sales; //Defines sales amount
            double commission = 0.025;
            double accelerator = 0.0125;
            double minSalesamt = 960000;
            double compensation; //Defines compensation object that combines salary + commission
            double overSales;
            double regCommission;
            double aclCommission;
     
            final int INCREMENT = 5000; //Defines sales increment to calculate potential compensation
            int total; // To hold the total sales in total
     
            DecimalFormat formatter = new DecimalFormat("#0.00");
     
            Scanner keyboard = new Scanner(System.in); //Code needed to prompt user to enter info on keyboard
     
            System.out.print("Enter total annual sales figure: $ "); //Prompts user to enter sales figure
            sales = keyboard.nextDouble(); 
     
           { 
            if (sales < minSalesamt)
            {
              compensation = salary;
              return compensation; //This represents everything less than the 80% of the $1.2M sales goal where no commission is paid
            }
            if (sales > targetSales)
            {
               overSales = (sales - targetSales);
               aclCommission = (overSales * (commission + accelerator));
     
                sales = targetSales;
     
             }
            else
            {
                aclCommission = 0;
            }
     
            regCommission = (sales  * commission);
     
            compensation = (salary + regCommission + aclCommission);
     
            System.out.println("Your total annual compensation is $" + compensation); //This code displays the total compensation including salary + commission
     
            System.out.println("Potential Total Sales\tMax Potential Salary Total");  // Display the table headings.
            System.out.println("------------------------------------------");
     
            for (total = (int) sales; total <= sales * 1.5; total += INCREMENT) // Loop to calculate the Total Potential Sales and Total Potential Compensation
            {
            System.out.printf("%20d\t\t%,.2f\n", total, compensation); // Display the Potential Total Sales and Total Potential Annual Compensation
    } 
          }
            return 0;
        }
    }


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    The main method signature cannot be changed if it is to be used by the JVM for starting a Java program, and so you'll want to re-review your notes or text. There you'll see that the return type must be declared as void, not as double. But regardless, it would make no sense to declare it as double. Sure, have other methods return values, but not the main since its sole purpose is to start your program running and that's it. You will usually never call it directly and so you would have no use for a return value.

  3. The Following User Says Thank You to curmudgeon For This Useful Post:

    Rick Sebastian (February 8th, 2013)

  4. #3
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    Thank you very much for your help! Now I'm finding that my calculations don't work either. This is very aggravating.

    I appreciate the help though.

  5. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    You're welcome.

    If you still need our help, then you'll want to show the latest code and go into detail on the current state of your problem. The statement, "calculations don't work...", doesn't tell us enough about what's wrong for us to be able to understand the problem or be able to suggest a solution. Also, are you printing out intermediate results using println statements (statements that will be removed prior to submitting your assignment)? This or a debugger can be quite useful for testing the state of the program and its variables as it runs.

  6. #5
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    Thank you very much for your help! Now I'm finding that my calculations don't work either. This is very aggravating.

    I appreciate the help though.

  7. #6
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    OK, then best of luck with the calculations.

    But again if you need our help, please re-read my post just above this one. Again "calculations don't work" tells us zip, nothing, nada.

  8. #7
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    Quote Originally Posted by curmudgeon View Post
    You're welcome.

    If you still need our help, then you'll want to show the latest code and go into detail on the current state of your problem. The statement, "calculations don't work...", doesn't tell us enough about what's wrong for us to be able to understand the problem or be able to suggest a solution. Also, are you printing out intermediate results using println statements (statements that will be removed prior to submitting your assignment)? This or a debugger can be quite useful for testing the state of the program and its variables as it runs.
    I am using NetBeans IDE 7.2.1 and I am BRAND NEW to Java programming and programming in general. So this is all very new and very confusing for me. So please let me apologize up front if I say something that sounds ridiculous. Having said that, here are the issues I'm still having:

    The whole point of this program is to calculate an annual salary for a sales person. The sales person gets a base salary of $60K and a commission on sales. The commission is as follows:

    On sales of $0 - $960K - 0%
    On sales of $960K - $1.2M - 2.5%
    On sales of $1.2M and above - 3.75%

    The program also needs to project an additional 50% above the actual sales in increments of $5K, and display what the sales person could have made in salary and commissions on that additional 50%.

    So.... That's where I need to be.

    Here is where I am.

    The program will print out the sales amount you input, and it will increment it by $5k up to $50 of the original amount.

    However, the program does NOT compute the correct commission initially, or on the incremented totals.

    I have tried to use "if" statements to boil down the salary and commission at all the steps into a common object called "compensation". However, the program is telling me that the "compensation" object is never used. (Even though it's included in the code where I *believe* it needs to be in order to do what I need the program to do.

    So once again I am stuck.

    I hope that makes sense.

    Here is the current code:

    package compensation;
    import java.text.DecimalFormat;
    import java.util.Scanner;
     
    /**
     * @author Rick Sebastian
     */
     
    public class Compensation 
    {
        public static void main(String[] args) 
        {        
            int salary = 60000;  //Defines base salary of $60K
            double targetSales = 120000; //Defines the target sales object to determine commission
            double sales; //Defines the sales total 
            double commission = 0.025;
            double accelerator = 0.0125;
            double minSalesamt = 960000;
            double compensation; //Defines compensation object that combines salary + commission
            double overSales;
            double regCommission;
            double aclCommission;
     
            final int INCREMENT = 5000; //Defines sales increment to calculate potential compensation
            int total; // To hold the total sales in total to increment by $5000
     
            DecimalFormat formatter = new DecimalFormat("#0.00");
     
            Scanner keyboard = new Scanner(System.in); //Code needed to prompt user to enter info on keyboard
     
            System.out.print("Enter total annual sales figure: $ "); //Prompts user to enter sales figure
            sales = keyboard.nextDouble(); 
     
           { 
     
            if (sales < minSalesamt)
            {
              compensation = salary;
              //return compensation;
            }
     
            if (sales >= minSalesamt)
            {
               regCommission = (sales * commission);
               compensation = regCommission + salary;
               //return compensation;
            }
     
            if (sales >= targetSales)
            {
               aclCommission = (sales * (commission + accelerator));
               compensation = (aclCommission + salary);
               //return compensation;
            }
     
            else
            {
               aclCommission = 0;
            }
     
            regCommission = (sales  * commission);
     
            compensation = (salary + regCommission + aclCommission);
     
            System.out.println("Your total annual compensation is $" + compensation); //This code displays the total compensation including salary + commission
     
            System.out.println("Potential Total Sales\tMax Potential Salary Total");  // Display the table headings.
            System.out.println("------------------------------------------");
     
            for (total = (int) sales; total <= sales * 1.5; total += INCREMENT) // Loop to calculate the Total Potential Sales and Total Potential Compensation
            {
            System.out.printf("%20d\t\t%,.2f\n", total, compensation); // Display the Potential Total Sales and Total Potential Annual Compensation
            } 
     
          }     
       }
     }


    --- Update ---

    I apologize.... I must have hit send twice on that same message....

    I'm completely frazzled over here...

  9. #8
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    Look at this loop:

             for (total = (int) sales; total <= sales * 1.5; total += INCREMENT) {
                System.out.printf("%20d\t\t%,.2f\n", total, compensation);
             }

    As you can see, total will increase as the loop progresses, but where do you change compensation inside of the loop? If it is not changed in the code, it will not be changed in the display.

    --- Update ---

    Also your math is off. You must calculate the first commission on amount *over* 960K, not on the total sales, and likewise for the higher commission. I don't see where you do this.

  10. #9
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    That's a very good point about calculating the commission on the incremented sales totals. Unfortunately, I have absolutely no idea how to do that in the loop.

    As for the math...

    I thought the statement:

            if (sales >= minSalesamt)
            {
               regCommission = (sales * commission);
               compensation = regCommission + salary;

    I thought this would only calculate a sales commission on sales over $960K (minSalesamt)? My understanding is it would apply (multiply) the "commission" rate of 0.025 to the "sales" figure, and the result would be stored in "compensation" object. No? So (for example) if I used a sales figure of $1,000,000 it *should* calculate a commission of $25K and add it to the salary of $60K and produce a total of $85K.

    That was my logic in doing what I did with this (and the other) calculations. Not sure why that's not working... Please explain.

  11. #10
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    Quote Originally Posted by curmudgeon View Post
    Look at this loop:

             for (total = (int) sales; total <= sales * 1.5; total += INCREMENT) {
                System.out.printf("%20d\t\t%,.2f\n", total, compensation);
             }

    As you can see, total will increase as the loop progresses, but where do you change compensation inside of the loop? If it is not changed in the code, it will not be changed in the display.

    --- Update ---

    Also your math is off. You must calculate the first commission on amount *over* 960K, not on the total sales, and likewise for the higher commission. I don't see where you do this.
    Can you please explain how to change the compensation inside the loop as it increments by $5K each time?

  12. #11
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    I'll leave the calculation code up to you as this is something that you should experiment a bit wih, but the key is that you must change compensation inside of the loop:

    for (total = (int) sales; total <= sales * 1.5; total += INCREMENT) {
     
      compensation = /*  do some calculating here using the increasing value of total to figure out what compensation should be  */
     
      System.out.printf("%20d\t\t%,.2f\n", total, compensation);
    }

    Best would be to have a separate method, say called calculateCompensation(double total) that uses the parameter to calculate and then return the compensation associated with the total passed in. Then this same method could be used in multiple places in your program.

  13. #12
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    I added this to the top of the code to add a sales persons name and their annual sales figure. The program will allow you to add the name of the first sales person, their sales, but then it skips over the line where you would add the name of the second sales person, and it stops on the line to add the sales figure for the second sales person. I've been playing with it for 5 hours now and I can't figure out why it won't stop to allow you to enter the second sales persons name. If you or anyone else can offer a suggestion I would be appreciative.

    package compensation;
    import java.text.DecimalFormat;
    import java.util.Scanner;
     
    /**
     * @author Rick Sebastian
     */
     
    public class Compensation 
    {
        public static void main(String[] args) 
        {        
            final int NUM_WORKERS = 2;    
            String salesPerson1;  //declare variables for arrary  
            String salesPerson2;  //declare variables for arrary  
     
            int[] workers = new int[NUM_WORKERS];  //number of employees to compare, and initialize array 
     
             Scanner keyboard = new Scanner(System.in);  //new scanner input 
     
             //get salesperson1 name  
             System.out.println("What is the name of the first of your "
                                + NUM_WORKERS + " employees?");  
             salesPerson1 =  keyboard.nextLine();  
     
             //get salesperson1 sales total  
             System.out.print("What was their sales total for the year?");  
             workers[0] = (int) keyboard.nextInt();  
     
             //get salesperson2 name  
             System.out.println("What is the name of the second of your "
                                + NUM_WORKERS + " employees?");  
             salesPerson2 =  keyboard.nextLine();  
     
             //get salesperson2 sales total  
             System.out.print("What was their sales total for the year?");  
             workers[1] = (int) keyboard.nextInt();  
     
             for (int index = 0; index < NUM_WORKERS; index++)  
             {  
                 System.out.printf("Salesperson: Total", index, workers[index]);  
             }

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

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    The Scanner class's nextInt() method leaves the line-end character in its buffer. If the next method called is nextLine() that method will return an empty String for the line-end character.
    You need an extra call to nextLine() to clear the end-line character before you will be able to read a line with the nextLine() method.
    If you don't understand my answer, don't ignore it, ask a question.

  15. The Following User Says Thank You to Norm For This Useful Post:

    Rick Sebastian (February 9th, 2013)

  16. #14
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Why am I getting a <No Main Classes Found> error message?? Help please!!

    That worked. Much thanks!

Similar Threads

  1. Replies: 5
    Last Post: January 28th, 2013, 05:07 AM
  2. Symbol not found error
    By ayuda96 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 25th, 2012, 04:48 PM
  3. [SOLVED] Error Message: Exception in thread "main" java.lang.NullPointerException etc.
    By coffecupcake in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 15th, 2011, 09:34 AM
  4. help with a error message
    By JavaNoob82 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 23rd, 2010, 02:56 PM
  5. Main Class Not Found Problem
    By shadow in forum Java Theory & Questions
    Replies: 3
    Last Post: September 29th, 2009, 09:42 AM