So I have a school assignment to do in Java, I have created the program but it does not give me an output. Im still a beginner so plz help me fix the problem. the first half of my code uses joptionpane but i want to display the output in the console. this is my code:
import java.util.Scanner;
import javax.swing.JOptionPane;
public class payroll2
{
public static void main(String args[])
{
new payroll2().SetPayrollDetail();
new payroll2().SetBonus();
new payroll2().SetCommission();
new payroll2().SetNssf();
new payroll2().SetNetSalary();
new payroll2().GetPayroll();
}
Scanner myScanner=new Scanner(System.in);
Double empID;
String empName;
String empDept;
String designation;
Double basicSalary;
Double bonus;
Double commission;
Double nssf;
Double netSalary;
public void SetPayrollDetail()
{
empID = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter ID: ", "ID",JOptionPane.QUESTION_MESSAGE));
empName = JOptionPane.showInputDialog(null, "Enter Name: ", "Name",JOptionPane.QUESTION_MESSAGE);
empDept = JOptionPane.showInputDialog(null, "Enter Department (Marketing or Other): ", "Department",JOptionPane.QUESTION_MESSAGE);
designation = JOptionPane.showInputDialog(null, "Enter Designation (Manager, Executive or Other): ", "Designation",JOptionPane.QUESTION_MESSAGE);
basicSalary = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter Basic Salary: ", "Basic Salary",JOptionPane.QUESTION_MESSAGE));
}
public void SetBonus()
{
if(basicSalary < 1500){
bonus = 0.0;
}
else if(basicSalary>=1500 && basicSalary<3000){
bonus = basicSalary * (12/100);
}
else if(basicSalary>=3000 && basicSalary<5000){
bonus = basicSalary * (15/100);
}
else{
bonus = basicSalary * (25/100);
}
System.out.println(bonus);
}
public void SetCommission()
{
if( empDept.equalsIgnoreCase("other") ){
commission = 0.0;
}
else if( empDept.equalsIgnoreCase("marketing") && designation.equalsIgnoreCase("manager") ){
commission = basicSalary * (30/100);
}
else if( empDept.equalsIgnoreCase("marketing") && designation.equalsIgnoreCase("executive") ){
commission = basicSalary * (15/100);
}
else if( empDept.equalsIgnoreCase("marketing") && designation.equalsIgnoreCase("other") ){
commission = basicSalary * (10/100);
}
else{
commission = 0.0;
}
System.out.println(commission);
}
public void SetNssf()
{
if(basicSalary < 1500){
nssf = basicSalary * (5/100);
}
else if(basicSalary>=1500 && basicSalary<3000){
nssf = basicSalary * (8/100);
}
else if(basicSalary>=3000 && basicSalary<5000){
nssf = basicSalary * (12/100);
}
else if(basicSalary>=5000 && basicSalary<7000){
nssf = basicSalary * (15/100);
}
else if(basicSalary>=7000 && basicSalary<10000){
nssf = basicSalary * (20/100);
}
else{
nssf = basicSalary * (25/100);
}
System.out.println(nssf);
}
public void SetNetSalary()
{
netSalary = ( basicSalary + commission + bonus ) - nssf;
System.out.println(netSalary);
}
public void GetPayroll()
{
System.out.println("Payroll Details \n _____________________");
System.out.println("ID:\t" + empID);
System.out.println("name:\t" + empName);
System.out.println(bonus);
System.out.println(commission);
System.out.println(nssf);
System.out.println(netSalary);
}
}