Results 1 to 5 of 5
- 11-17-2012, 09:51 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 57
- Rep Power
- 0
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:
Which I believe is all correct....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 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??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;}}
That having been said, any advice would be golden, and I will be waiting on the edge of my seat here!!
- 11-18-2012, 02:47 AM #2
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"?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 11-19-2012, 10:36 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
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.
- 11-19-2012, 10:56 AM #4
Member
- Join Date
- Nov 2012
- Posts
- 57
- Rep Power
- 0
- 11-19-2012, 11:37 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
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.Please do not ask for code as refusal often offends.
Similar Threads
-
Running main method class from another main class
By tlrocketman in forum New To JavaReplies: 3Last Post: 12-06-2010, 08:30 AM -
How to run tow main class exsit in one project
By AhmedAdel in forum New To JavaReplies: 9Last Post: 04-20-2010, 11:51 AM -
How can I change the main class of a project?
By batya in forum AWT / SwingReplies: 2Last Post: 11-17-2009, 07:55 PM -
Compiling/Running Project in Command Line: "Could not find main class" Error
By Yasemin Gokce in forum New To JavaReplies: 1Last Post: 06-30-2009, 02:32 PM -
How to create main class link to another two class?
By pearllymary78 in forum New To JavaReplies: 6Last Post: 07-16-2008, 11:02 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks