Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Maybe is very simple thing but I could not figure out.
Harry Geri
Greenhorn
Posts: 4
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I cannot figure out Why result of pay rate also showing as a work hours.It is not even ask the work hours.
package payroll; import javax.swing.JOptionPane; public class payroll { public static void main(String[] args) { String name; String employeeID; String temp; String temp2; int hours ; double rate; // Get a employee name. do { name = JOptionPane.showInputDialog("Please " + "Enter your Name:"); }while((name == null) || (name.length() == 0)); // Get a employee ID. do { employeeID = JOptionPane.showInputDialog("Enter " + "a customer number in the form LLLNNNN\n" + "(LL = letters and NNNN = numbers)"); }while((employeeID == null) || (employeeID.length() == 0)|| (!isValid(employeeID))); if (!isValid(employeeID)) // Get a employee work hours. do { temp= JOptionPane.showInputDialog("Please " + "Enter your work hours"); hours = Integer.parseInt(temp); }while(hours < 1 || hours > 84); // Get a employee pay rate. do { temp2 = JOptionPane.showInputDialog("Please " + "Enter your pay rate"); rate = Integer.parseInt(temp2); }while(rate < 1 || rate > 25); // Display the results. JOptionPane.showMessageDialog(null,"Employee name: " +name+" " +"\nEmployee ID: " +employeeID+" " +"\nEmployee work hours: " +temp2+" hours" +"\nEmployee pay rate:$" +rate+" "); { return; } } private static boolean isValid(String custNumber) { boolean goodSoFar = true; // Flag int i = 0; // Control variable // Test the length. if (custNumber.length() != 6) goodSoFar = false; // Test the first three characters for letters. while (goodSoFar && i < 2) { if (!Character.isLetter(custNumber.charAt(i))) goodSoFar = false; i++; } // Test the last four characters for digits. while (goodSoFar && i < 6) { if (!Character.isDigit(custNumber.charAt(i))) goodSoFar = false; i++; } return goodSoFar; } }
Knute Snortum
Sheriff
Posts: 7125
184
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You're only asking for the work hours if the employee ID is not valid.
All things are lawful, but not all things are profitable.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Review
Report employee time clock cannot find corresponding dates in and out
Identifier expected
While Loop with Sentinel issues
Java
More...