In class I have to create a java program that has to use the user method. Here is my code.

1 import java.text.*;
2 import javax.swing.*;
3 import java.io.*;
4 public class Fahrenheit3
5 {
6 public static void main (String [] args)throws Exception
7 {
8 String inFahrenheit;
9 Double f,
10 c;
11 char input;
12 int yes=1, no=2;
13
14 do
15 {
16 inFahrenheit= JOptionPane.showInputDialog("Enter a Number");
17 f=Double.parseDouble(inFahrenheit);
18 c=(f-32.0) * (5.0/9.0);
19 // input= JOptionPane.showInputDialog(null,"Do you want to continue?");
20 input=Double.parseDouble(inFahrenheit);
21 }
22
23 while (JOptionPane.showInputDialog (null,"Do you want to continue");//.charAt(0) == 'y');
24
25 }

i think u will need a Jframe for the dialog box , a button and an action listener. U have ignored event handling functions

frame = new JFrame("Show Message Dialog");
    JButton button = new JButton("Click Me");

Use actionPerformed method of the ActionListener interface

I think u should first try a simple "do you wish to continue" feature with a test program.

U have given frame as null that may be ok but what about event

In class I have to create a java program that has to use the user method. Here is my code.

1 import java.text.*;
2 import javax.swing.*;
3 import java.io.*;
4 public class Fahrenheit3
5 {
6 public static void main (String [] args)throws Exception
7 {
8 String inFahrenheit;
9 Double f,
10 c;
11 char input;
12 int yes=1, no=2;
13
14 do
15 {
16 inFahrenheit= JOptionPane.showInputDialog("Enter a Number");
17 f=Double.parseDouble(inFahrenheit);
18 c=(f-32.0) * (5.0/9.0);
19 // input= JOptionPane.showInputDialog(null,"Do you want to continue?");
20 input=Double.parseDouble(inFahrenheit);
21 }
22
23 while (JOptionPane.showInputDialog (null,"Do you want to continue");//.charAt(0) == 'y');
24
25 }

Code tags. Use them, and get rid of the line numbers. The code tags will add them for you. No one can do anything with the code with the numbers in there.

[code=JAVA] // paste code here

[/code]

What's the question?

In class I have to create a java program that has to use the  user method.

Don't assume we know what you mean by "the user method". And what's this program supposed to do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.