[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

Java Applet

Asked by Maymoon125 in New to Java Programming

Tags: java applet

Hi all I'm trying to write a temperature conversion Applet that converts from Fahrenheit to celsius and also convertes to Kelvin. i need the program to be able to make conversions between any three scales.
the code will compile but the calculations are wrong
I did some codes but i dont like what i did maybe some body can help me with my codes
thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
// Temperature Conversion Applet
import java.applet.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
 
public class calculator
	extends Applet
  	implements ActionListener
{
  	private TextField tfInput, tfResult;
  	private Button btF2C, btC2F,btF2K, btK2F, btC2K, btK2C;
 
  	private final String F2C = new String("Fahrenheit to Celsius");
  	private final String C2F = new String("Celsius to Fahrenheit");
  	private final String F2K = new String("Fahrenheit to Kelvin");
  	private final String K2F = new String("Kelvin to Fahrenheit");
  	private final String C2K = new String("Celsius to Kelvin");
  	private final String K2C = new String("Kelvin to Celsius");
 
  	//initialize user interface
  	public void init()
  	{
    	     	//set layout and foreground colors
    	     	setLayout(new BorderLayout());
    	     	setBackground(Color.white);
	     	setFont(new Font("Times New Roman", Font.PLAIN, 14));
 
    	     	//create text fields
    	     	tfInput = new TextField(6);
    	     	tfResult = new TextField(6);
 
            //set result field read only
    	     	tfResult.setEditable(false);
 
    	     	//create buttons
    	     	btF2C = new Button(F2C);
    	     	btC2F = new Button(C2F);
    	     	btF2K = new Button(F2K);
    	     	btK2F = new Button(K2F);
    	     	btC2K = new Button(C2K);
    	     	btK2C = new Button(K2C);
 
	     	//register listeners
    	     	btF2C.addActionListener(this);
    	     	btC2F.addActionListener(this);
    	     	btF2K.addActionListener(this);
    	     	btK2F.addActionListener(this);
    	     	btC2K.addActionListener(this);
    	     	btK2C.addActionListener(this);
 
    	     	//create 3 panels
    	     	Panel p1 = new Panel();
	     	p1.add(new Label(
	"Enter a temperature and select conversion type:"));
	     	p1.add(tfInput);
 
	     	Panel p2 = new Panel();
	     	p2.add(new Label("Result:"));
	     	p2.add(tfResult);
 
    	     	Panel p3 = new Panel();
    	     	p3.add(btF2C);
    	     	p3.add(btC2F);
    	     	p3.add(btF2K);
    	     	p3.add(btK2F);
    	     	p3.add(btC2K);
    	     	p3.add(btK2C);
 
		// add panels to frame
    	     	add(BorderLayout.NORTH, p1);
    	     	add(BorderLayout.CENTER, p2);
    	     	add(BorderLayout.SOUTH, p3);
  	}
 
	//event handler for buttons
  	public void actionPerformed(ActionEvent e)
  	{
    	     String actionCommand = e.getActionCommand();
    	     double t1, t2,t3,t4,t5,t6, t7;
    	     // get input temp
    	     t1=(Double.valueOf(tfInput.getText())).doubleValue();
 
    	     // compute result
    	     //F2C = (((t1 - 32) / 9) * 5);
    	     t2=actionCommand.equals(F2C) ? 5*(t1-32)/9 : 9*t1/5 + 32 ;
    	     t3=actionCommand.equals(F2K) ? (5*(t1-32)/9+273.15) : 9*t1/5 +305.15;
 
    	     // display result
    	     tfResult.setText(String.valueOf(t2));
	}
}
 
***************************************
<html>
<applet code = "calculator.class" width = "1000" height = "300">
</applet>
</html>
[+][-]11/04/09 11:15 AM, ID: 25742787Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: New to Java Programming
Tags: java applet
Sign Up Now!
Solution Provided By: jb1dev
Participating Experts: 1
Solution Grade: A
 
[+][-]11/04/09 11:20 AM, ID: 25742849Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 04:07 PM, ID: 25745553Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 05:50 PM, ID: 25746084Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 06:02 PM, ID: 25746141Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 11:54 AM, ID: 25753237Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625