Exercise 2 Code

Exercise 2 Code - file:/X|/cs101/Exercise2_1.txt import

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
file:///X|/cs101/Exercise2_1.txt import javax.swing.JOptionPane; public class Exercise2_1 { // Main method public static void main(String[] args) { // Enter a temperature in Fahrenheit String fahrenheitString = JOptionPane.showInputDialog(null, "Enter a temperature in fahrenheit:", "Exercise2_1 Input", JOptionPane.QUESTION_MESSAGE); // Convert string to double double fahrenheit = Double.parseDouble(fahrenheitString); // Convert it to Celsius double celsius = (5.0 / 9.0) * (fahrenheit - 32); // Display the result JOptionPane.showMessageDialog(null, "The temperature is " + celsius + " in Celsius"); } } file:///X|/cs101/Exercise2_1.txt [4/29/2008 12:07:42 PM]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
file:///X|/cs101/Exercise2_2.txt import javax.swing.JOptionPane; public class Exercise2_2 { public static void main(String[] args) { // Enter radius of the cylinder String radiusString = JOptionPane.showInputDialog(null, "Enter radius of the cylinder", "Exercise2_2 Input", JOptionPane.QUESTION_MESSAGE); // Convert string to double double radius = Double.parseDouble(radiusString);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Exercise 2 Code - file:/X|/cs101/Exercise2_1.txt import

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online