Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By Tolls

Thread: Need to create or set main class for project

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

    Question Need to create or set main class for project

    I am creating an employee payroll program in NetBeans 7.2, but even though I believe I have the coding correct for what I am trying to do, I cannot even run the program to test it because I keep getting a window popup that says, "No Main Classes found" I have tried to create a new class and set it as main several times, and I have tried revising existing classes to try to make them the main class, but nothing will work. Anyway, here is my code from the first file, followed by the code from the second:
    Java Code:
    package salescommission;
    import java.util.Scanner;
    public class Payrate {    
        private double salary;
        private double commission = .05;
        private double accelFactor = 1.25;
        private double accelCommission;
        private double targetSales = 100000;
        private double percentSales;
        private double maxPotentialSales;
        private double potentialSales;    
        Payrate() {salary = 50000; //base salary
        }   public double calculateCommission(double sales) {        
            percentSales = sales/targetSales;
            accelCommission = commission * accelFactor;        
            if (percentSales >= .8) { //sales minimum for commission achieved
                if (percentSales >= 1 ) { //sales minimum for accel factor achieved
                    return salary + (sales * accelCommission); 
                }return salary + (sales * commission);
            }return salary; //sales minimum not achieved
        }public void potentialComp(double sales) {
            maxPotentialSales = sales*1.5; //calculate 50 percent above annual sales
            potentialSales = sales;         
            while (potentialSales <= maxPotentialSales) { System.out.println("    $" + String.format("%1$,.2f",potentialSales) 
                        + "            $" + 
                      String.format("%1$,.2f",calculateCommission(potentialSales)));
                potentialSales = potentialSales + 5000;}}
        public double isValid(Scanner input, String prompt) {
            double sales = 0.0;
            boolean valid = false;
            while (valid == false) { //Allow user to recover from error
                System.out.print(prompt); //display message
                if (input.hasNextDouble()) { //check if input is a number
                    sales = input.nextDouble();  //store cmd input
                    if (sales < 0) {System.out.println("Please enter a positive number. Try "
                                           + "again");} else {valid = true;}
                } else {System.out.println("Please enter a number. Try again.");}
                input.nextLine();}
            return sales;}}
    Which I believe is all correct....
    Java Code:
    package salescommission;
    import java.util.Scanner;
    public class Commission {    
        private double salary;
        private double commission = .05;
        private double accelFactor = 1.25;
        private double accelCommission;
        private double targetSales = 100000;
        private double percentSales;
        private double maxPotentialSales;
        private double potentialSales;
        public void main(String[] args) {
            salary = 50000;} //Standard Employee Pay
        public double calculateCommission(double sales) {        
            percentSales = sales/targetSales;
            accelCommission = commission * accelFactor;        
            if (percentSales >= .8) { //sales minimum for commission achieved
                if (percentSales >= 1 ) { //sales minimum for accel factor achieved
                    return salary + (sales * accelCommission); 
                }return salary + (sales * commission);}        
            return salary; }//No COmmission    
        public void potentialComp(double sales) {
            maxPotentialSales = sales*1.5; //calculate 50 percent above annual sales
            potentialSales = sales;         
            while (potentialSales <= maxPotentialSales) {
                System.out.println("    $" + String.format("%1$,.2f",potentialSales) 
                        + "            $" + 
                      String.format("%1$,.2f",calculateCommission(potentialSales)));
                potentialSales = potentialSales + 5000;}}    
        public double isValid(Scanner input, String prompt) {
            double sales = 0.0;
            boolean valid = false;
            while (valid == false) { //Allow user to recover from error
                System.out.print(prompt); //display message
                if (input.hasNextDouble()) { //check if input is a number
                    sales = input.nextDouble();  //store cmd input
                    if (sales < 0) { //check for negative value
                        System.out.println("Please enter a positive number. Try "
                                           + "again");}
                 else {valid = true;}}
                 else {System.out.println("Please enter a number. Try again.");}
                 input.nextLine();}
                 return sales;}}
    which should work together with the first file to complete the operations, but as I said, I cannot even test this because it won't even try to run until I can have a main class??
    That having been said, any advice would be golden, and I will be waiting on the edge of my seat here!!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,252
    Rep Power
    19

    Default Re: Need to create or set main class for project

    Moved from New to Java.

    NetBeans comes with an extensive Help system. Did you try searching the help for "set main class"?

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

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: Need to create or set main class for project

    How do you run this?
    It could be the scrappy layout, but I can't see a main() method in there.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

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

    Question Re: Need to create or set main class for project

    Quote Originally Posted by Tolls View Post
    How do you run this?
    It could be the scrappy layout, but I can't see a main() method in there.
    It does not run, it tells me there is no main class.... That is why I posted this question, to be able to add a main class??

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: Need to create or set main class for project

    Java needs an entry point.
    For a basic Java app that entry point is a main() method.
    See the HelloWorld explanation at the Oracle tutorials.
    DarrylBurke likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Running main method class from another main class
    By tlrocketman in forum New To Java
    Replies: 3
    Last Post: 12-06-2010, 08:30 AM
  2. How to run tow main class exsit in one project
    By AhmedAdel in forum New To Java
    Replies: 9
    Last Post: 04-20-2010, 11:51 AM
  3. How can I change the main class of a project?
    By batya in forum AWT / Swing
    Replies: 2
    Last Post: 11-17-2009, 07:55 PM
  4. Replies: 1
    Last Post: 06-30-2009, 02:32 PM
  5. How to create main class link to another two class?
    By pearllymary78 in forum New To Java
    Replies: 6
    Last Post: 07-16-2008, 11:02 PM

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
  •