Your code needs a little re-ordering. For example your class variables should be outside any methods. Also, displayWeeklySalary is an instance method, so acts on an instance of your class, so you can't just call it from the main method without instantiating some kind of salary object.
So either like this:
CODE
import javax.swing.*;
public class Salary
{
double hourlyRate = 25.0;
double regularHours = 40.0;
double overtimeHours = 13.0;
public static void main(String[] args)
{
Salary s = new Salary();
s.displayWeeklySalary();
System.exit(0);
}
public void displayWeeklySalary()
{
//weeklySalary =
JOptionPane.showMessageDialog(null,
"The employee's weekly salary for " + regularHours +
"regular hours and " + overtimeHours +
"\novertime hours at " + hourlyRate + "per hour is: $"
+ calcSalary(hourlyRate, regularHours, overtimeHours));
}
public static double calcSalary(double regularHours, double overtimeHours, double hourlyRate)
{
return (regularHours * hourlyRate) + (overtimeHours * (1.5 * hourlyRate));
}
}
Or like this:
CODE
import javax.swing.*;
class SalaryMethods
{
double hourlyRate = 25.0;
double regularHours = 40.0;
double overtimeHours = 13.0;
public void displayWeeklySalary()
{
//weeklySalary =
JOptionPane.showMessageDialog(null,
"The employee's weekly salary for " + regularHours +
"regular hours and " + overtimeHours +
"\novertime hours at " + hourlyRate + "per hour is: $"
+ calcSalary(hourlyRate, regularHours, overtimeHours));
}
public static double calcSalary(double regularHours, double overtimeHours, double hourlyRate)
{
return (regularHours * hourlyRate) + (overtimeHours * (1.5 * hourlyRate));
}
}
public class Salary {
public static void main(String[] args)
{
SalaryMethods s = new SalaryMethods();
s.displayWeeklySalary();
System.exit(0);
}
}