All pastes #23072 Raw Edit

Miscellany

public java v1 · immutable
#23072 ·published 2005-09-16 07:26 UTC
rendered paste body
import java.io.IOException;import java.io.InputStreamReader;import java.io.LineNumberReader;/** * this class converts c to f and f to c *  * @author blah * @version blah */public class conv {        /**     * Shortcut to System.out.println()     *      * @param text String to display to console     */    private static void display (String text) {        System.out.println(text);    }        public static void main() {        display ("this converts c to f");                LineNumberReader _in = new LineNumberReader(new InputStreamReader(System.in));        int resolvedChar = 0;        String num = null;        String choice = null;        while (                num == null &&                 !(choice.equals("q") || choice.equals("Q")) &&                 !(num.equals("q") || num.equals("Q"))         ) {                           display ("input number or Q to quit: ");                        try {                 num = _in.readLine();                display("Inputted number: "+num);                display("Choose: ");                display("1) convert C > F");                display("2) convert F > C");                display("Q) Quit Program");                try {                    choice = _in.readLine();                    if ( choice.equals("1") ) {                        double tempNum = Integer.parseInt(num);                        // formula to convert c > f here...i dont know it                        tempNum *= 1; // <--- formula here                        display ("Number converted C > F: "+tempNum);                    }                    else if ( choice.equals("2") ) {                        double tempNum = Integer.parseInt(num);                        // formula to convert f > c here...i dont know it                        tempNum *= 1; // <--- formula here                        display ("Number converted F > C: "+tempNum);                    }                }                catch ( IOException e ) {                     display("IO Error: "+e);                 }             }            catch ( IOException e ) {                 display("IO Error: "+e);             }        }        display("Bye");    }}