Hey guys,
This is my first topic.
I tried my very best to keep behind the scenes and not make a thread about this, but its been ticking me off for a while now.. The "while" loop im using.. i can only get the last user input to display or to be used in math equations.. when i need every user input to be used. the program I am working on consists of getting employee salary and pay rate information.. SO heres the code:
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
//
String strOption, strHour, strSalary, strPay, strWorker;
int option;
int worker;
int selections;
double hour;
double pay = 0;
double salary = 0;
double month;
double week = 0;
selections = 0;
strOption = JOptionPane.showInputDialog("Menu options:\n1. Enter Hourly Employee\n2. Enter Salaried Employee\n0. Done\n Please select a menu option:");
option = Integer.parseInt(strOption);
//start outer
while (option >= 3) {
JOptionPane.showMessageDialog(null, "Sorry, " + (option) + " is not a valid option.");
strOption = JOptionPane.showInputDialog("Menu options:\n1. Enter Hourly Employee\n2. Enter Salaried Employee\n0. Done\n Please select a menu option: ");
option = Integer.parseInt(strOption);
}
switch (option) {
case 0:
JOptionPane.showMessageDialog(null, "Goodbye.");
break;
case 1:
strWorker = JOptionPane.showInputDialog("how many employees are on hourly base pay?");
worker = Integer.parseInt(strWorker);
strHour = JOptionPane.showInputDialog("Enter the number of hours per week:");
hour = Double.parseDouble(strHour);
while (selections < worker) {
strPay = JOptionPane.showInputDialog("Enter the hourly pay rate :");
pay = Double.parseDouble(strPay);
selections++;
}
JOptionPane.showMessageDialog(null, (pay));
break;
case 2:
selections = 1;
strWorker = JOptionPane.showInputDialog("how many employees?");
worker = Integer.parseInt(strWorker);
while (selections <= worker) {
strSalary = JOptionPane.showInputDialog("Enter the Yearly salary:");
salary = Double.parseDouble(strSalary);
selections++;
}
selections = worker;
month = salary / 4.3;
JOptionPane.showMessageDialog(null, (month));
}
strOption = JOptionPane.showInputDialog("Menu options:\n1. Enter Hourly Employee\n2. Enter Salaried Employee\n0. Done\n Please select a menu option: ");
System.exit(0);
}
}
another problem im having is that i cant seem to get the menu option to revert back to the case statements after execution. case .. it just exits.. =( and yet another problem is that when i click cancel.. it exits with an error about exception in Main thread.. if i can get these little things cleared up i can actually the rest of the things i need to do like make the math equations.. but i cant do that until these problems are solved.. thanks guys