I made this sample program for a while, and I'm figuring out how to add the sum of the two employees' pay I inputted in the array. Any suggestions?
import javax.swing.JOptionPane;
public class Sample {
public static void main (String[] args)
{
String Name;
int i, HoursWorked, Rate, Pay=0, TotalPay=0, GrandTotalPay=0;
int CivStatus=0, Single=500, Married=1000;
System.out.println("Name\t\t\t\tCivil Status Code\t\t\tPay");
int [] Employees = new int [2];
for (i=0; i<Employees.length; i++)
{
Name=JOptionPane.showInputDialog("Enter your name: ");
HoursWorked=Integer.parseInt(JOptionPane.showInputDialog("Enter hours worked: "));
Rate=Integer.parseInt(JOptionPane.showInputDialog("Enter hourly rate: "));
Pay=HoursWorked*Rate;
CivStatus=Integer.parseInt(JOptionPane.showInputDialog("Enter your civil status: \nEnter [1] if single.\nEnter [2] if married."));
if(CivStatus==1){
{
TotalPay=Pay-Single;
}
}
if(CivStatus==2){
{
TotalPay=Pay-Married;
}
}
GrandTotalPay=Employees[0]+Employees[1];
System.out.println(Name+"\t\t\t\t"+CivStatus+"\t\t\t\t\t"+Pay);
}
System.out.println("The sum of the pay is: "+GrandTotalPay);
}
}