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" :(think): 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:
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....
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!! :(handshake):
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
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.
Re: Need to create or set main class for project
Quote:
Originally Posted by
Tolls
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?? :(think):
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.