public static void main(String[] args) { Scanner keyboard = new Scanner (System.in); float x; int y; char ch1, ch2; String name; String input; input = JOptionPane.showInputDialog("Enter a number: "); // int y y = Integer.parseInt(input); name = JOptionPane.showInputDialog("Enter a name: "); // String name input = JOptionPane.showInputDialog("Enter a floating point value: "); // Float x x = Float.parseFloat(input); JOptionPane.showMessageDialog(null, "ch1 = " + ch1 + "y = " + y + "\nName is " + name + "\nx = " + x); System.exit(0); // output }
So far so good on this part ^^
But, I also have a question about "char ch1 and ch2". I am not sure how to convert the char to a string.
System.out.print("Enter a character: "); input = keyboard.next(); ch1 = input.charAt(0); to JOptionPane.showInputDialog("Enter a character: "); input = keyboard.next(); ch1 = input.charAt(0);
I know that ^^ is wrong just not sure where to go from the original code.