markHANNA
February 21st, 2010, 08:12 PM
hey fellas I am brand new to both java programming and codeguru. I have been working on a program for a few hours. and have continually failed to finish it, and was wondering if you guys could help me out.
so far I have written:
import javax.swing.JOptionPane;
public class GetOption {
public static void main(String[] args) {
String input = "";
String str;
str = "Would You Consider Yourself:\r\n\r\n" "a: A Beginner\r\n"
"b: Experienced\r\n" "c: An Expert\r\n\r\n" "Enter a, b, or c:";
do {
input = JOptionPane.showInputDialog(null, str);
if (input != null
&& (input.equalsIgnoreCase("a") || input.equalsIgnoreCase("b") || input
.equalsIgnoreCase("c"))) {
break;
} else {
JOptionPane.showMessageDialog(null, "You must use abc.");
}
} while (true);
// * now use the information in the input variable!
int dollarsPerHour = 0;
if (input.equalsIgnoreCase("a")) {
dollarsPerHour = 10;
} else if (input.equalsIgnoreCase("b")) {
dollarsPerHour = 15;
} else if (input.equalsIgnoreCase("c")) {
dollarsPerHour = 20;
}}}
however, how should I go about adding an input dialog box that then asks how many hours the user worked? and then based on this answer, shows an information dialog box that says:
"(the amount of hours the user just input) at $(the rate shown depending on if the user chose 1, 2, or 3 earlier) makes $(the sum of: the amount of hours the user imput * the rate the user gets depending on if they chose 1 2 or 3)"
haha i know it's kinda complicated and I am completely lost as to how to finish this program.
any and all help would be greatly appreciated!
thanks again,
-Mark
so far I have written:
import javax.swing.JOptionPane;
public class GetOption {
public static void main(String[] args) {
String input = "";
String str;
str = "Would You Consider Yourself:\r\n\r\n" "a: A Beginner\r\n"
"b: Experienced\r\n" "c: An Expert\r\n\r\n" "Enter a, b, or c:";
do {
input = JOptionPane.showInputDialog(null, str);
if (input != null
&& (input.equalsIgnoreCase("a") || input.equalsIgnoreCase("b") || input
.equalsIgnoreCase("c"))) {
break;
} else {
JOptionPane.showMessageDialog(null, "You must use abc.");
}
} while (true);
// * now use the information in the input variable!
int dollarsPerHour = 0;
if (input.equalsIgnoreCase("a")) {
dollarsPerHour = 10;
} else if (input.equalsIgnoreCase("b")) {
dollarsPerHour = 15;
} else if (input.equalsIgnoreCase("c")) {
dollarsPerHour = 20;
}}}
however, how should I go about adding an input dialog box that then asks how many hours the user worked? and then based on this answer, shows an information dialog box that says:
"(the amount of hours the user just input) at $(the rate shown depending on if the user chose 1, 2, or 3 earlier) makes $(the sum of: the amount of hours the user imput * the rate the user gets depending on if they chose 1 2 or 3)"
haha i know it's kinda complicated and I am completely lost as to how to finish this program.
any and all help would be greatly appreciated!
thanks again,
-Mark