Instructions

The day after these are assigned we will cover solutions in class. After that, I will post the solutions online.

Assignments

  1. Temperature Conversion You are to write a Java applet that allows the user to enter a temperature in Celsius and converts it to Fahrenheit. Remember that the equation is:
    F = (C * 9/5) + 32
    Specifically, do the following:
    1. Create a new project in Eclipse called "TempConverter"
    2. Create a new Java class called "TempConverter"
    3. Use the sample code from the Generic program we covered yesterday.
    4. Modify it to the following: Change the label to say "Enter Degrees Celsius: ".
    5. Modify the button to say "Convert to Fahrenheit"
    6. When the user enters a number in the input field and then clicks the button, your program should output (in the output/textarea field), the sentence:
      "The Fahrenheit equivalent of X degrees Celsius is Y"
      Where X is whatever the user entered and Y is the Fahrenheit equivalent.
    Install Java to see the solution!



  2. Computing Powers Java has no operator to do exponents. I.e. xy cannot be done directly in Java. You are to write a program that allows the user t enter two number, base and power, and your program must output the value of basepower.

    Specifically, do the following:
    1. Create a new project in Eclipse called "Powers"
    2. Create a new Java class called "Powers"
    3. Use the sample code from the Generic program we covered yesterday.
    4. Modify it to the following ways...
    5. Change the label to say "Base: ".
    6. Add a new label between the input field and the button called "Exponent: "
    7. Add a new input field (JTextField) between this new label and the button
    8. Change the button to say "Compute Power"
    9. When the user enters two numbers and clicks the button, display the result in the output window.
    Install Java to see the solution!