001package template.ftoc;
002import java.io.BufferedReader;
003import java.io.InputStreamReader;
004import java.io.IOException;
005
006/* This example is from Robert C. Martin */
007public class Main {
008        public static void main(String[] args) {
009                (new FtoC()).run();
010        }
011}
012/* public */
013abstract class Application {
014        private boolean isDone = false;
015
016        protected abstract void init();
017        protected abstract void idle();
018        protected abstract void cleanup();
019        protected boolean done() {
020                return isDone;
021        }
022        protected void setDone() {
023                isDone = true;
024        }
025        public void run() {
026                init();
027                while (!done())
028                        idle();
029                cleanup();
030        }
031}
032final class FtoC extends Application {
033        private BufferedReader br;
034
035        protected void init() {
036                br = new BufferedReader(new InputStreamReader(System.in));
037        }
038        protected void idle() {
039                String fstring = readLine();
040                if (fstring == null || fstring.length() == 0) {
041                        setDone();
042                } else {
043                        double f = Double.parseDouble(fstring);
044                        double c = 5.0/9.0*(f-32);
045                        System.out.println("F=" + f + ", C=" + c);
046                }
047        }
048        protected void cleanup() {
049                System.out.println("FtoC exit");
050        }
051        private String readLine() {
052                try { return br.readLine(); }
053                catch(IOException e) { return null; }
054        }
055}